How to use the @bentley/bentleyjs-core.Guid.createValue function in @bentley/bentleyjs-core

To help you get started, we’ve selected a few @bentley/bentleyjs-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / core / frontend / src / IModelApp.ts View on Github external
RpcConfiguration.requestContext.getId = (_request: RpcRequest): string => {
      const id = ClientRequestContext.current.useContextForRpc ? ClientRequestContext.current.activityId : Guid.createValue(); // Use any context explicitly set for an RPC call if possible
      ClientRequestContext.current.useContextForRpc = false; // Reset flag so it doesn't get used inadvertently for next RPC call
      return id;
    };
github imodeljs / imodeljs / ui / framework / src / clientservices / DefaultProjectServices.ts View on Github external
public async getProjects(accessToken: AccessToken, projectScope: ProjectScope, top: number, skip: number, filter?: string): Promise {
    const alctx = new ActivityLoggingContext(Guid.createValue());

    const queryOptions: ConnectRequestQueryOptions = {
      $select: "*", // TODO: Get Name,Number,AssetType to work
      $top: top,
      $skip: skip,
      $filter: filter,
    };

    let projectList: Project[];
    try {
      if (projectScope === ProjectScope.Invited) {
        projectList = await this._connectClient.getInvitedProjects(alctx, accessToken, queryOptions);
      }

      if (projectScope === ProjectScope.Favorites) {
        queryOptions.isFavorite = true;
github imodeljs / imodeljs / core / frontend / src / IModelApp.ts View on Github external
public static startup(opts?: IModelAppOptions): void {
    opts = opts ? opts : {};

    if (this._initialized)
      throw new IModelError(IModelStatus.AlreadyLoaded, "startup may only be called once");

    // Setup a current context for all requests that originate from this frontend
    const requestContext = new FrontendRequestContext();
    requestContext.enter();

    this._initialized = true;

    // Initialize basic application details before log messages are sent out
    this.sessionId = (opts.sessionId !== undefined) ? opts.sessionId : Guid.createValue();
    this._applicationId = (opts.applicationId !== undefined) ? opts.applicationId : "2686";  // Default to product id of iModel.js
    this._applicationVersion = (opts.applicationVersion !== undefined) ? opts.applicationVersion : (typeof BUILD_SEMVER !== "undefined" ? BUILD_SEMVER : "");
    this.authorizationClient = opts.authorizationClient;

    this._imodelClient = (opts.imodelClient !== undefined) ? opts.imodelClient : new IModelHubClient();

    this._setupRpcRequestContext();

    // get the localization system set up so registering tools works. At startup, the only namespace is the system namespace.
    this._i18n = (opts.i18n instanceof I18N) ? opts.i18n : new I18N("iModelJs", opts.i18n);

    // first register all the core tools. Subclasses may choose to override them.
    const coreNamespace = this.i18n.registerNamespace("CoreTools");
    [
      selectTool,
      idleTool,
github imodeljs / imodeljs / core / backend / src / IModelDb.ts View on Github external
public createSnapshot(snapshotFile: string): IModelDb {
    IModelJsFs.copySync(this.briefcase.pathname, snapshotFile);
    const briefcaseEntry: BriefcaseEntry = BriefcaseManager.openStandalone(snapshotFile, OpenMode.ReadWrite, false);
    const isSeedFileMaster: boolean = BriefcaseId.Master === briefcaseEntry.briefcaseId;
    const isSeedFileSnapshot: boolean = BriefcaseId.Snapshot === briefcaseEntry.briefcaseId;
    // Replace iModelId if seedFile is a master or snapshot, preserve iModelId if seedFile is an iModelHub-managed briefcase
    if ((isSeedFileMaster) || (isSeedFileSnapshot)) {
      briefcaseEntry.iModelId = Guid.createValue();
    }
    briefcaseEntry.briefcaseId = BriefcaseId.Snapshot;
    const snapshotDb: IModelDb = IModelDb.constructIModelDb(briefcaseEntry, OpenParams.standalone(OpenMode.ReadWrite)); // WIP: clean up copied file on error?
    if (isSeedFileMaster) {
      snapshotDb.setGuid(briefcaseEntry.iModelId);
    } else {
      snapshotDb.setAsMaster(briefcaseEntry.iModelId);
    }
    snapshotDb.nativeDb.setBriefcaseId(briefcaseEntry.briefcaseId);
    return snapshotDb;
  }
github imodeljs / imodeljs / core / backend / src / IModelHost.ts View on Github external
public static startup(configuration: IModelHostConfiguration = new IModelHostConfiguration()) {
    if (IModelHost.configuration)
      throw new IModelError(BentleyStatus.ERROR, "startup may only be called once", Logger.logError, loggerCategory, () => (configuration));

    IModelHost.sessionId = Guid.createValue();

    // Setup a current context for all requests that originate from this backend
    const requestContext = new BackendRequestContext();
    requestContext.enter();

    if (!MobileRpcConfiguration.isMobileBackend) {
      this.validateNodeJsVersion();
    }
    this.backendVersion = require("../package.json").version;
    initializeRpcBackend();

    const region: number = Config.App.getNumber(UrlDiscoveryClient.configResolveUrlUsingRegion, 0);
    if (!this._isNativePlatformLoaded) {
      try {
        if (configuration.nativePlatform !== undefined)
          this.registerPlatform(configuration.nativePlatform, region);
github imodeljs / imodeljs / test-apps / testbed / frontend / performance / IModelApi.ts View on Github external
public static async getIModelByName(accessToken: AccessToken, projectId: string, iModelName: string): Promise {
    const alctx = new ActivityLoggingContext(Guid.createValue());
    const queryOptions = new IModelQuery();
    queryOptions.select("*").top(100).skip(0);
    const iModels: HubIModel[] = await IModelApi._hubClient.iModels.get(alctx, accessToken, projectId, queryOptions);
    if (iModels.length < 1)
      return undefined;
    for (const thisIModel of iModels) {
      if (!!thisIModel.id && thisIModel.name === iModelName) {
        const versions: Version[] = await IModelApi._hubClient.versions.get(alctx, accessToken, thisIModel.id!, new VersionQuery().select("Name,ChangeSetId").top(1));
        if (versions.length > 0) {
          thisIModel.latestVersionName = versions[0].name;
          thisIModel.latestVersionChangeSetId = versions[0].changeSetId;
        }
        return thisIModel;
      }
    }
    return undefined;
github imodeljs / imodeljs / test-apps / presentation-test-app / src / frontend / api / MyAppFrontend.ts View on Github external
public static getClientId(): string {
    const key = "presentation-test-app/client-id";
    let value = window.localStorage.getItem(key);
    if (!value) {
      value = Guid.createValue();
      window.localStorage.setItem(key, value);
    }
    return value;
  }
}
github imodeljs / imodeljs / test-apps / testbed / frontend / TestData.ts View on Github external
public static async getTestIModelId(accessToken: AccessToken, projectId: string, iModelName: string): Promise {
    const alctx = new ActivityLoggingContext(Guid.createValue());
    const iModels = await TestData.imodelClient.iModels.get(alctx, accessToken, projectId, new IModelQuery().byName(iModelName));
    assert(iModels.length > 0);
    assert(iModels[0].wsgId);

    return iModels[0].wsgId;
  }
}
github imodeljs / imodeljs / presentation / common / src / KeySet.ts View on Github external
this.addKeySet(value, pred);
    } else if (this.isKeysArray(value)) {
      value.forEach((key) => (!pred || pred(key)) ? this.add(key) : undefined);
    } else if (Key.isEntityProps(value)) {
      this.add({ className: value.classFullName, id: Id64.fromJSON(value.id) } as InstanceKey);
    } else if (Key.isInstanceKey(value)) {
      if (!this._instanceKeys.has(value.className))
        this._instanceKeys.set(value.className, new Set());
      this._instanceKeys.get(value.className)!.add(value.id);
    } else if (Key.isNodeKey(value)) {
      this._nodeKeys.add(JSON.stringify(value));
    } else {
      throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
    }
    if (this.size !== sizeBefore)
      this._guid = Guid.createValue();
    return this;
  }
github imodeljs / imodeljs / presentation / frontend / src / RulesetManager.ts View on Github external
public async add(ruleset: Ruleset): Promise {
    const registered = new RegisteredRuleset(ruleset, Guid.createValue(), (r: RegisteredRuleset) => this.remove(r));
    if (!this._clientRulesets.has(ruleset.id))
      this._clientRulesets.set(ruleset.id, []);
    this._clientRulesets.get(ruleset.id)!.push(registered);
    return registered;
  }