gdc-sdk-node-ts 2.4.13 → 2.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -371,6 +371,7 @@ export class HttpRuntimeClient {
371
371
  async provisionOrganizationEmployee(ctx, input) {
372
372
  return provisionOrganizationEmployeeWithDeps(ctx, input, {
373
373
  createEmployee: (routeContext, creation) => this.createOrganizationEmployee(routeContext, creation),
374
+ confirmLicenseOrder: (routeContext, licenseOrder) => this.confirmOrganizationLicenseOrder(routeContext, licenseOrder),
374
375
  issueLicense: (routeContext, invitation) => this.issueOrganizationEmployeeLicense(routeContext, invitation),
375
376
  });
376
377
  }
@@ -1,25 +1,38 @@
1
1
  import { type EmployeeActivationGrant, type OrganizationEmployeeLifecycleRecord } from 'gdc-common-utils-ts';
2
2
  import type { RouteContext } from './individual-onboarding.js';
3
3
  import type { SubmitAndPollResult } from './orchestration/client-port.js';
4
+ import type { OrganizationLicenseOrderConfirmInput } from './organization-license-order.js';
4
5
  import type { ServerProfileEnrollmentInput, ServerProfileRecord } from './server-profile-session.js';
5
6
  import type { LicenseListRuntimeSearchInput, OrganizationEmployeeCreationInput, OrganizationEmployeeLicenseInvitationInput, OrganizationEmployeeSearchInput } from './resource-operations.js';
6
- /** Input for the atomic controller-facing create plus seat issuance workflow. */
7
+ /**
8
+ * Input for atomic interactive provisioning. Every current employee create is
9
+ * seat-required. Supplying `licenseOrder` authorizes the SDK to close a
10
+ * GW-issued Offer before retrying creation and issuing the activation
11
+ * credential. A future batch import requires a separate explicit operation.
12
+ */
7
13
  export type OrganizationEmployeeProvisioningInput = Readonly<{
8
14
  creation: OrganizationEmployeeCreationInput;
9
15
  invitation: OrganizationEmployeeLicenseInvitationInput;
16
+ licenseOrder?: Omit<OrganizationLicenseOrderConfirmInput, 'offerId'>;
10
17
  }>;
11
18
  /** Results required by a portal to persist routing and display the credential once. */
12
19
  export type OrganizationEmployeeProvisioningResult = Readonly<{
13
20
  employee: SubmitAndPollResult;
14
21
  license: SubmitAndPollResult;
22
+ licenseOrder?: SubmitAndPollResult;
15
23
  activationCode: string;
16
24
  }>;
17
25
  /** Shared dependencies for the create plus seat issuance workflow. */
18
26
  export type OrganizationEmployeeProvisioningDeps = Readonly<{
19
27
  createEmployee(routeContext: RouteContext, input: OrganizationEmployeeCreationInput): Promise<SubmitAndPollResult>;
20
28
  issueLicense(routeContext: RouteContext, input: OrganizationEmployeeLicenseInvitationInput): Promise<SubmitAndPollResult>;
29
+ confirmLicenseOrder?(routeContext: RouteContext, input: OrganizationLicenseOrderConfirmInput): Promise<SubmitAndPollResult>;
21
30
  }>;
22
- /** Creates the employee, reserves its seat and returns the exact GW credential. */
31
+ /**
32
+ * Creates the employee, closing Offer/Order first when the strict request has
33
+ * no available seat, then reserves that seat through `License/_issue` and
34
+ * returns the exact GW activation credential.
35
+ */
23
36
  export declare function provisionOrganizationEmployeeWithDeps(routeContext: RouteContext, input: OrganizationEmployeeProvisioningInput, deps: OrganizationEmployeeProvisioningDeps): Promise<OrganizationEmployeeProvisioningResult>;
24
37
  /**
25
38
  * Rejects failed outer HTTP responses and failed entries hidden inside a
@@ -2,17 +2,52 @@
2
2
  import { createHash } from 'node:crypto';
3
3
  import { ActorKinds, EmployeeActivationGrantVersions, projectOrganizationEmployeeLifecycle, readEmployeeActivationCode, } from 'gdc-common-utils-ts';
4
4
  import { buildStableActorIdentifier } from 'gdc-common-utils-ts/utils/actor-identifier';
5
- /** Creates the employee, reserves its seat and returns the exact GW credential. */
5
+ import { ClaimsOfferSchemaorg } from 'gdc-common-utils-ts/constants/schemaorg';
6
+ /**
7
+ * Creates the employee, closing Offer/Order first when the strict request has
8
+ * no available seat, then reserves that seat through `License/_issue` and
9
+ * returns the exact GW activation credential.
10
+ */
6
11
  export async function provisionOrganizationEmployeeWithDeps(routeContext, input, deps) {
7
- const employee = await deps.createEmployee(routeContext, input.creation);
12
+ const creation = input.creation;
13
+ let employee = await deps.createEmployee(routeContext, creation);
8
14
  assertSuccessfulEmployeeOperation('employee creation', employee);
15
+ let licenseOrder;
16
+ const offerId = readEmployeeLicenseOfferId(employee.poll.body);
17
+ if (offerId) {
18
+ if (!input.licenseOrder || !deps.confirmLicenseOrder) {
19
+ throw new Error('provisionOrganizationEmployee: employee creation requires Offer/Order confirmation before licence issue.');
20
+ }
21
+ licenseOrder = await deps.confirmLicenseOrder(routeContext, {
22
+ ...input.licenseOrder,
23
+ offerId,
24
+ });
25
+ assertSuccessfulEmployeeOperation('licence order confirmation', licenseOrder);
26
+ employee = await deps.createEmployee(routeContext, creation);
27
+ assertSuccessfulEmployeeOperation('employee creation retry', employee);
28
+ if (readEmployeeLicenseOfferId(employee.poll.body)) {
29
+ throw new Error('provisionOrganizationEmployee: employee creation still requires a licence after Order confirmation.');
30
+ }
31
+ }
9
32
  const license = await deps.issueLicense(routeContext, input.invitation);
10
33
  assertSuccessfulEmployeeOperation('licence issue', license);
11
34
  const activationCode = readEmployeeActivationCode(license.poll.body);
12
35
  if (!activationCode) {
13
36
  throw new Error('provisionOrganizationEmployee: GW response did not contain an employee activation credential.');
14
37
  }
15
- return { employee, license, activationCode };
38
+ return { employee, license, licenseOrder, activationCode };
39
+ }
40
+ function readEmployeeLicenseOfferId(value) {
41
+ for (const candidate of nestedRecords(value)) {
42
+ if (candidate.type !== 'Employee-license-offer-v1.0')
43
+ continue;
44
+ const meta = record(candidate.meta);
45
+ const claims = record(meta?.claims);
46
+ const offerId = String(claims?.[ClaimsOfferSchemaorg.identifier] || '').trim();
47
+ if (offerId)
48
+ return offerId;
49
+ }
50
+ return undefined;
16
51
  }
17
52
  /**
18
53
  * Rejects failed outer HTTP responses and failed entries hidden inside a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-sdk-node-ts",
3
- "version": "2.4.13",
3
+ "version": "2.4.15",
4
4
  "description": "Next-generation Node runtime package for the GDC SDK family",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Antifraud Services Inc.",
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "build": "tsc -p tsconfig.json",
15
+ "prepare": "npm run build",
15
16
  "type-check": "tsc -p tsconfig.json --noEmit",
16
17
  "check:product-neutrality": "node scripts/check-product-neutrality.mjs",
17
18
  "prepublishOnly": "npm run check:product-neutrality && npm run type-check && npm test",
@@ -37,7 +38,7 @@
37
38
  "test:e2e:live-gw:clean": "bash ./scripts/run-live-gw-clean.sh"
38
39
  },
39
40
  "dependencies": {
40
- "gdc-common-utils-ts": "2.5.7",
41
+ "gdc-common-utils-ts": "2.5.11",
41
42
  "gdc-sdk-core-ts": "~2.3.18"
42
43
  },
43
44
  "devDependencies": {