@sixtyninecommerce/admin 0.8.0 → 0.10.0
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.
- package/README.md +2739 -17
- package/dist/api-tokens/index.d.ts +15 -5
- package/dist/api-tokens/index.js +1 -0
- package/dist/apps/event-subscription.d.ts +59 -0
- package/dist/apps/event-subscription.js +32 -0
- package/dist/apps/hook-secret.d.ts +22 -0
- package/dist/apps/hook-secret.js +36 -0
- package/dist/apps/index.d.ts +54 -3
- package/dist/apps/index.js +17 -0
- package/dist/audit/index.d.ts +7 -0
- package/dist/auth/queries.d.ts +5 -1
- package/dist/auth/queries.js +6 -0
- package/dist/bulk/index.d.ts +323 -0
- package/dist/bulk/index.js +162 -0
- package/dist/catalog/assets.d.ts +147 -0
- package/dist/catalog/assets.js +164 -0
- package/dist/catalog/collections.d.ts +109 -0
- package/dist/catalog/collections.js +91 -0
- package/dist/catalog/facets.d.ts +103 -0
- package/dist/catalog/facets.js +100 -0
- package/dist/catalog/index.d.ts +115 -0
- package/dist/catalog/index.js +21 -0
- package/dist/catalog/options.d.ts +89 -0
- package/dist/catalog/options.js +88 -0
- package/dist/catalog/products-bulk.d.ts +21 -0
- package/dist/catalog/products-bulk.js +58 -0
- package/dist/catalog/products.d.ts +650 -0
- package/dist/catalog/products.js +458 -0
- package/dist/catalog/properties.d.ts +234 -0
- package/dist/catalog/properties.js +158 -0
- package/dist/catalog/types.d.ts +174 -0
- package/dist/catalog/types.js +141 -0
- package/dist/catalog/variants.d.ts +324 -0
- package/dist/catalog/variants.js +288 -0
- package/dist/catalog/visibility.d.ts +57 -0
- package/dist/catalog/visibility.js +59 -0
- package/dist/client.d.ts +192 -3
- package/dist/client.js +87 -12
- package/dist/compliance/index.d.ts +88 -0
- package/dist/compliance/index.js +88 -0
- package/dist/customer-data-redaction.d.ts +14 -0
- package/dist/customer-data-redaction.js +22 -0
- package/dist/customers/index.d.ts +428 -17
- package/dist/customers/index.js +322 -15
- package/dist/documents/index.d.ts +513 -16
- package/dist/documents/index.js +229 -3
- package/dist/events/index.d.ts +259 -0
- package/dist/events/index.js +147 -0
- package/dist/feeds/ai.d.ts +46 -0
- package/dist/feeds/ai.js +43 -0
- package/dist/feeds/categories.d.ts +50 -0
- package/dist/feeds/categories.js +56 -0
- package/dist/feeds/configs.d.ts +54 -0
- package/dist/feeds/configs.js +85 -0
- package/dist/feeds/identifier-fields.d.ts +25 -0
- package/dist/feeds/identifier-fields.js +29 -0
- package/dist/feeds/index.d.ts +54 -0
- package/dist/feeds/index.js +46 -0
- package/dist/feeds/preserve.d.ts +38 -0
- package/dist/feeds/preserve.js +74 -0
- package/dist/feeds/rules.d.ts +42 -0
- package/dist/feeds/rules.js +56 -0
- package/dist/feeds/types.d.ts +654 -0
- package/dist/feeds/types.js +135 -0
- package/dist/fulfillments/index.d.ts +437 -0
- package/dist/fulfillments/index.js +534 -0
- package/dist/heads/index.d.ts +60 -0
- package/dist/heads/index.js +45 -0
- package/dist/hooks/assignments.d.ts +90 -0
- package/dist/hooks/assignments.js +53 -0
- package/dist/hooks/index.d.ts +97 -0
- package/dist/hooks/index.js +76 -0
- package/dist/index.d.ts +95 -9
- package/dist/index.js +21 -1
- package/dist/integrations/index.d.ts +14 -0
- package/dist/integrations/index.js +9 -0
- package/dist/integrations/pipelines.d.ts +113 -0
- package/dist/integrations/pipelines.js +62 -0
- package/dist/integrations/types.d.ts +176 -0
- package/dist/integrations/types.js +8 -0
- package/dist/jobs/bulk-action-run.d.ts +74 -0
- package/dist/jobs/bulk-action-run.js +69 -0
- package/dist/locations/index.d.ts +6 -2
- package/dist/meta/index.d.ts +32 -0
- package/dist/orders/bulk.d.ts +75 -0
- package/dist/orders/bulk.js +150 -0
- package/dist/orders/commit-edit.d.ts +123 -0
- package/dist/orders/commit-edit.js +142 -0
- package/dist/orders/deposit-policy.d.ts +103 -0
- package/dist/orders/deposit-policy.js +202 -0
- package/dist/orders/get.d.ts +722 -0
- package/dist/orders/get.js +530 -0
- package/dist/orders/index.d.ts +186 -21
- package/dist/orders/index.js +57 -0
- package/dist/orders/line-price-preview.d.ts +297 -0
- package/dist/orders/line-price-preview.js +50 -0
- package/dist/orders/manual-discounts.d.ts +141 -0
- package/dist/orders/manual-discounts.js +97 -0
- package/dist/orders/manual-pricing.d.ts +192 -0
- package/dist/orders/manual-pricing.js +72 -0
- package/dist/orders/order-entry.d.ts +566 -0
- package/dist/orders/order-entry.js +129 -0
- package/dist/orders/parcel-charge.d.ts +45 -0
- package/dist/orders/parcel-charge.js +55 -0
- package/dist/orders/plan-edit.d.ts +489 -0
- package/dist/orders/plan-edit.js +93 -0
- package/dist/orders/status.d.ts +235 -0
- package/dist/orders/status.js +96 -0
- package/dist/orders/surcharges.d.ts +75 -2
- package/dist/orders/surcharges.js +110 -4
- package/dist/payments/account-credit.d.ts +171 -0
- package/dist/payments/account-credit.js +107 -0
- package/dist/payments/index.d.ts +241 -9
- package/dist/payments/index.js +92 -0
- package/dist/payments/methods.d.ts +37 -0
- package/dist/payments/methods.js +33 -0
- package/dist/platform/catalog.d.ts +148 -0
- package/dist/platform/catalog.js +74 -0
- package/dist/platform/entitlements.d.ts +111 -0
- package/dist/platform/entitlements.js +86 -0
- package/dist/platform/legal-entities.d.ts +139 -0
- package/dist/platform/legal-entities.js +126 -0
- package/dist/platform/legal-entity-numbering.d.ts +103 -0
- package/dist/platform/legal-entity-numbering.js +101 -0
- package/dist/platform/organization-membership.d.ts +80 -0
- package/dist/platform/organization-membership.js +71 -0
- package/dist/platform/organization-settings.d.ts +33 -0
- package/dist/platform/organization-settings.js +42 -0
- package/dist/platform/organization-sharing.d.ts +172 -0
- package/dist/platform/organization-sharing.js +120 -0
- package/dist/platform/organizations.d.ts +205 -0
- package/dist/platform/organizations.js +180 -0
- package/dist/platform/provision-store.d.ts +88 -8
- package/dist/platform/provision-store.js +12 -0
- package/dist/platform/reports.d.ts +46 -0
- package/dist/platform/reports.js +31 -0
- package/dist/platform/server-metrics.d.ts +58 -0
- package/dist/platform/server-metrics.js +11 -0
- package/dist/pos/index.d.ts +567 -0
- package/dist/pos/index.js +205 -0
- package/dist/pricing/index.d.ts +408 -0
- package/dist/pricing/index.js +353 -0
- package/dist/pricing/vouchers.d.ts +103 -0
- package/dist/pricing/vouchers.js +69 -0
- package/dist/provenance/index.d.ts +93 -0
- package/dist/provenance/index.js +53 -0
- package/dist/reports/index.d.ts +199 -0
- package/dist/reports/index.js +154 -0
- package/dist/returns/index.d.ts +225 -0
- package/dist/returns/index.js +160 -0
- package/dist/search/index.d.ts +99 -0
- package/dist/search/index.js +62 -0
- package/dist/shipping/parcel-count-suggestion.d.ts +52 -0
- package/dist/shipping/parcel-count-suggestion.js +73 -0
- package/dist/shipping/parcel-rule.d.ts +48 -0
- package/dist/shipping/parcel-rule.js +91 -0
- package/dist/stock/index.d.ts +166 -0
- package/dist/stock/index.js +115 -0
- package/dist/stock/transfers.d.ts +520 -0
- package/dist/stock/transfers.js +437 -0
- package/dist/stored-value/index.d.ts +154 -0
- package/dist/stored-value/index.js +130 -0
- package/dist/tenant/capabilities.d.ts +10 -0
- package/dist/tenant/entitlements.d.ts +35 -0
- package/dist/tenant/entitlements.js +15 -0
- package/dist/tenant/field-groups.d.ts +64 -0
- package/dist/tenant/field-groups.js +34 -0
- package/dist/tenant/legal-entity.d.ts +32 -0
- package/dist/tenant/legal-entity.js +41 -0
- package/dist/tenant/notifications.d.ts +148 -0
- package/dist/tenant/notifications.js +79 -0
- package/dist/tenant/retention.d.ts +10 -4
- package/dist/tenant/settings-sources.d.ts +103 -0
- package/dist/tenant/settings-sources.js +92 -0
- package/dist/types.d.ts +86 -11
- package/dist/uploads/index.d.ts +11 -7
- package/dist/users/index.d.ts +104 -0
- package/dist/users/index.js +80 -0
- package/package.json +3 -2
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type Page, type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call, ListOptions } from '../types.js';
|
|
3
|
+
import type { CommittedPipelineDraft, ImportDependency, PipelineDirection, PipelineDraft, PipelineDraftSummary, UpdatePipelineDraftInput, UpdatePipelineDraftSchemaMapInput } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Every key whose VALUE is stored data, not DTO shape: the platform's passthrough set
|
|
6
|
+
* (`credentials`, `public_credentials`, `site_analysis`, `trigger_filter`, …) plus a schema map's
|
|
7
|
+
* jsonb columns, which carry the source's own field names and sample records. Converting them
|
|
8
|
+
* would rename a sample's `date_created` to `dateCreated`, and a `triggerFilter`'s `toState` would
|
|
9
|
+
* reach the reader as `to_state`, which it ignores.
|
|
10
|
+
*/
|
|
11
|
+
export declare const PIPELINE_DRAFT_PRESERVE_KEYS: ReadonlySet<string>;
|
|
12
|
+
/**
|
|
13
|
+
* A creation probes the source over the network, and a commit creates the pipeline and may start
|
|
14
|
+
* its run: both outlast the SDK's 15-second default on a slow source.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PIPELINE_DRAFT_SLOW_TIMEOUT_MS = 60000;
|
|
17
|
+
/**
|
|
18
|
+
* Half-finished import and export set-ups, kept on the server for the store (headless spec §7).
|
|
19
|
+
*
|
|
20
|
+
* - **Any admin of the store with pipeline rights (`UpdateCatalog`) continues a draft, from any
|
|
21
|
+
* device.** Drafts belong to the store, not to the person who started one: the list shows every
|
|
22
|
+
* unfinished set-up of the active store, and another store's draft is `PIPELINE_DRAFT_NOT_FOUND`.
|
|
23
|
+
* - **Kept 7 days after its LAST change.** Every write moves `expiresAt`; reads do not. An expired
|
|
24
|
+
* draft answers `PIPELINE_DRAFT_NOT_FOUND` at once, and the platform then deletes it together
|
|
25
|
+
* with the connection (and its stored password) the draft created, unless a pipeline or another
|
|
26
|
+
* draft uses that connection. A connection that existed before any draft is never deleted; one
|
|
27
|
+
* another draft created is the picking draft's too (`connection.createdByDraft`), and goes when
|
|
28
|
+
* the last draft holding it lets go of it unused.
|
|
29
|
+
* - **A draft never holds a secret.** Credentials go to {@link PipelineDraftsModule.connect} only,
|
|
30
|
+
* which creates the connection and stores them there, encrypted. A set-up resumed before its
|
|
31
|
+
* connection exists asks for the credentials again; the source URL and the other settings are
|
|
32
|
+
* kept.
|
|
33
|
+
* - **Every change names the `version` it was made against** and answers the draft with the next
|
|
34
|
+
* one. A change made on an older version is refused with a `ConflictError` coded
|
|
35
|
+
* `PIPELINE_DRAFT_CONFLICT` (409) and changes nothing: another admin, or another tab, changed it
|
|
36
|
+
* first. Read it again and reapply.
|
|
37
|
+
* - What a step still needs is a `BusinessRuleError` coded `PIPELINE_DRAFT_INCOMPLETE` (422) whose
|
|
38
|
+
* `details[]` name each field; a change the set-up refuses (a step of the other direction, a
|
|
39
|
+
* connector that cannot work in it) is a `ValidationError` coded `PIPELINE_DRAFT_INVALID` (400).
|
|
40
|
+
* - An organization workspace is not a store and is refused every door; an app below
|
|
41
|
+
* `customerData: full` is too, and `connect` refuses every app (`APP_CREDENTIAL_NOT_ALLOWED`).
|
|
42
|
+
*/
|
|
43
|
+
export interface PipelineDraftsModule {
|
|
44
|
+
/** The store's unexpired drafts, newest first. */
|
|
45
|
+
list(options?: ListOptions): Promise<Page<PipelineDraftSummary>>;
|
|
46
|
+
/**
|
|
47
|
+
* One draft with its connection, discovery status, schema maps, the served dependencies and their
|
|
48
|
+
* warnings, and the name the configure step would suggest in the store's zone. Poll it while
|
|
49
|
+
* `discovery.status` is `pending` or `running`.
|
|
50
|
+
*/
|
|
51
|
+
get(id: string, options?: Call): Promise<PipelineDraft>;
|
|
52
|
+
/** Start a set-up. The schedule zone starts as the store's, and the step is `connector`. */
|
|
53
|
+
create(input: {
|
|
54
|
+
direction: PipelineDirection;
|
|
55
|
+
}, options?: Call): Promise<PipelineDraft>;
|
|
56
|
+
/**
|
|
57
|
+
* Change fields. `connectorType` starts the connection over (no source URL, connection,
|
|
58
|
+
* discovery or stock location), even for the same connector; `direction` alone moves to the
|
|
59
|
+
* connector step; entering `configure` with no name gives the default one. A credential is
|
|
60
|
+
* refused here (400): send it to {@link PipelineDraftsModule.connect}.
|
|
61
|
+
*/
|
|
62
|
+
update(id: string, input: UpdatePipelineDraftInput, options?: Call): Promise<PipelineDraft>;
|
|
63
|
+
/**
|
|
64
|
+
* Create the draft's connection from its connector, source URL, throttle and legacy hosts, plus
|
|
65
|
+
* the `credentials` sent now: the source is probed first (a failed probe saves nothing), then
|
|
66
|
+
* the credentials are stored encrypted ON THE CONNECTION, never on the draft. The draft then
|
|
67
|
+
* owns the connection, so discarding or expiring it deletes the connection too. A previous
|
|
68
|
+
* connection the draft created, and its discovery, are let go.
|
|
69
|
+
*/
|
|
70
|
+
connect(id: string, input: {
|
|
71
|
+
version: number;
|
|
72
|
+
credentials: Record<string, string>;
|
|
73
|
+
}, options?: Call): Promise<PipelineDraft>;
|
|
74
|
+
/**
|
|
75
|
+
* Use one of the store's existing connections. Discarding the draft never deletes a connection
|
|
76
|
+
* that existed before any draft; one another draft created and still holds is this draft's too
|
|
77
|
+
* (`connection.createdByDraft` says so), and the last draft to let go of it unused deletes it.
|
|
78
|
+
*/
|
|
79
|
+
useConnection(id: string, input: {
|
|
80
|
+
version: number;
|
|
81
|
+
connectionId: string;
|
|
82
|
+
}, options?: Call): Promise<PipelineDraft>;
|
|
83
|
+
/** Start the discovery of an import draft's connection; poll {@link PipelineDraftsModule.get}. */
|
|
84
|
+
discover(id: string, input: {
|
|
85
|
+
version: number;
|
|
86
|
+
}, options?: Call): Promise<PipelineDraft>;
|
|
87
|
+
/** Change one schema map of the draft's discovery. */
|
|
88
|
+
updateSchemaMap(id: string, entityType: string, input: UpdatePipelineDraftSchemaMapInput, options?: Call): Promise<PipelineDraft>;
|
|
89
|
+
/**
|
|
90
|
+
* Save the draft as a pipeline and delete the draft; with `startRun` also start its first run.
|
|
91
|
+
* A run that does not start leaves the pipeline in place and answers `runError`. Takes an
|
|
92
|
+
* `idempotencyKey`: a commit retried after a lost answer replays the first one.
|
|
93
|
+
*/
|
|
94
|
+
commit(id: string, input: {
|
|
95
|
+
version: number;
|
|
96
|
+
startRun?: boolean;
|
|
97
|
+
}, options?: Call): Promise<CommittedPipelineDraft>;
|
|
98
|
+
/**
|
|
99
|
+
* Delete the draft, and the connection it created with its stored password unless a pipeline
|
|
100
|
+
* or another draft uses it.
|
|
101
|
+
*/
|
|
102
|
+
discard(id: string, options?: Call): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
/** Data pipelines (imports and exports between the store and another system). */
|
|
105
|
+
export interface IntegrationPipelinesModule {
|
|
106
|
+
drafts: PipelineDraftsModule;
|
|
107
|
+
/**
|
|
108
|
+
* What each importable entity type needs imported first, from the import writers themselves
|
|
109
|
+
* (the warnings' data; the words are yours).
|
|
110
|
+
*/
|
|
111
|
+
importDependencies(options?: Call): Promise<ImportDependency[]>;
|
|
112
|
+
}
|
|
113
|
+
export declare function createIntegrationPipelinesModule(transport: Transport): IntegrationPipelinesModule;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createPage, PLATFORM_PASSTHROUGH_KEYS, readRestPage, } from '@sixtyninecommerce/core';
|
|
2
|
+
/**
|
|
3
|
+
* Every key whose VALUE is stored data, not DTO shape: the platform's passthrough set
|
|
4
|
+
* (`credentials`, `public_credentials`, `site_analysis`, `trigger_filter`, …) plus a schema map's
|
|
5
|
+
* jsonb columns, which carry the source's own field names and sample records. Converting them
|
|
6
|
+
* would rename a sample's `date_created` to `dateCreated`, and a `triggerFilter`'s `toState` would
|
|
7
|
+
* reach the reader as `to_state`, which it ignores.
|
|
8
|
+
*/
|
|
9
|
+
export const PIPELINE_DRAFT_PRESERVE_KEYS = new Set([
|
|
10
|
+
...PLATFORM_PASSTHROUGH_KEYS,
|
|
11
|
+
'source_schema',
|
|
12
|
+
'sourceSchema',
|
|
13
|
+
'target_schema',
|
|
14
|
+
'targetSchema',
|
|
15
|
+
'sub_counts',
|
|
16
|
+
'subCounts',
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* A creation probes the source over the network, and a commit creates the pipeline and may start
|
|
20
|
+
* its run: both outlast the SDK's 15-second default on a slow source.
|
|
21
|
+
*/
|
|
22
|
+
export const PIPELINE_DRAFT_SLOW_TIMEOUT_MS = 60_000;
|
|
23
|
+
const DRAFTS = '/pipelines/drafts';
|
|
24
|
+
const segment = (value) => encodeURIComponent(value);
|
|
25
|
+
export function createIntegrationPipelinesModule(transport) {
|
|
26
|
+
const read = (path, options) => transport.rest('plugins', { method: 'GET', path }, { ...options, preserveKeys: PIPELINE_DRAFT_PRESERVE_KEYS });
|
|
27
|
+
const write = (method, path, body, options, timeoutMs) => transport.rest('plugins', { method, path, body }, {
|
|
28
|
+
...options,
|
|
29
|
+
preserveKeys: PIPELINE_DRAFT_PRESERVE_KEYS,
|
|
30
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
31
|
+
});
|
|
32
|
+
async function list(options) {
|
|
33
|
+
const body = await transport.rest('plugins', {
|
|
34
|
+
method: 'GET',
|
|
35
|
+
path: DRAFTS,
|
|
36
|
+
query: { after: options?.after, limit: options?.limit },
|
|
37
|
+
}, { ...options, preserveKeys: PIPELINE_DRAFT_PRESERVE_KEYS });
|
|
38
|
+
const { items, meta } = readRestPage(body);
|
|
39
|
+
return createPage(items, meta, (cursor) => list({ ...options, after: cursor }));
|
|
40
|
+
}
|
|
41
|
+
const drafts = {
|
|
42
|
+
list,
|
|
43
|
+
get: (id, options) => read(`${DRAFTS}/${segment(id)}`, options),
|
|
44
|
+
create: (input, options) => write('POST', DRAFTS, input, options),
|
|
45
|
+
update: (id, input, options) => write('PATCH', `${DRAFTS}/${segment(id)}`, input, options),
|
|
46
|
+
connect: (id, input, options) => write('POST', `${DRAFTS}/${segment(id)}/connection`, input, options, PIPELINE_DRAFT_SLOW_TIMEOUT_MS),
|
|
47
|
+
useConnection: (id, input, options) => write('POST', `${DRAFTS}/${segment(id)}/connection/existing`, input, options),
|
|
48
|
+
discover: (id, input, options) => write('POST', `${DRAFTS}/${segment(id)}/discover`, input, options),
|
|
49
|
+
updateSchemaMap: (id, entityType, input, options) => write('PATCH', `${DRAFTS}/${segment(id)}/schema-maps/${segment(entityType)}`, input, options),
|
|
50
|
+
commit: (id, input, options) => write('POST', `${DRAFTS}/${segment(id)}/commit`, input, options, PIPELINE_DRAFT_SLOW_TIMEOUT_MS),
|
|
51
|
+
async discard(id, options) {
|
|
52
|
+
await transport.rest('plugins', { method: 'DELETE', path: `${DRAFTS}/${segment(id)}`, expect: 'void' }, options);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
drafts,
|
|
57
|
+
async importDependencies(options) {
|
|
58
|
+
const body = await read('/pipelines/import-dependencies', options);
|
|
59
|
+
return body.data;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes of `admin.integrations.pipelines` (headless spec §7 `pipelines.drafts`).
|
|
3
|
+
*
|
|
4
|
+
* Kept verbatim (stored data, never renamed): `triggerFilter`'s keys (reader field names such as
|
|
5
|
+
* `toState`), `siteAnalysis` and `publicCredentials` (the connector's own keys), and a schema
|
|
6
|
+
* map's `sourceSchema`, `targetSchema` and `subCounts`.
|
|
7
|
+
*/
|
|
8
|
+
export type PipelineDirection = 'import' | 'export';
|
|
9
|
+
/** The wizard's steps before a commit; `import`/`done` come after one, when no draft exists. */
|
|
10
|
+
export type PipelineDraftStep = 'direction' | 'connector' | 'credentials' | 'discovery' | 'review' | 'entities' | 'trigger' | 'configure' | 'preview';
|
|
11
|
+
export type PipelineSyncPolicy = 'preserve_local' | 'always_source';
|
|
12
|
+
export type PipelineScheduleType = 'one_time' | 'daily' | 'weekly' | 'custom';
|
|
13
|
+
export type PipelineTriggerType = 'manual' | 'scheduled';
|
|
14
|
+
/** One draft in the store's list. */
|
|
15
|
+
export interface PipelineDraftSummary {
|
|
16
|
+
id: string;
|
|
17
|
+
direction: PipelineDirection;
|
|
18
|
+
step: PipelineDraftStep;
|
|
19
|
+
connectorType: string | null;
|
|
20
|
+
/** The pipeline's name, once the configure step gave it one. */
|
|
21
|
+
name: string | null;
|
|
22
|
+
connectionId: string | null;
|
|
23
|
+
discoveryId: string | null;
|
|
24
|
+
/** Send it back with the next change; a change made on an older one is refused 409. */
|
|
25
|
+
version: number;
|
|
26
|
+
/** Vendure User.id of whoever started it (an API token's own administrator for a token). */
|
|
27
|
+
createdByUserId: string;
|
|
28
|
+
updatedByUserId: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
/** 7 days after the last change; the draft answers 404 from then on. */
|
|
32
|
+
expiresAt: string;
|
|
33
|
+
}
|
|
34
|
+
/** The connection a draft holds. Never a credential: `publicCredentials` holds non-password fields only. */
|
|
35
|
+
export interface PipelineDraftConnection {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
connectorType: string;
|
|
39
|
+
sourceUrl: string;
|
|
40
|
+
status: string;
|
|
41
|
+
/** Soft-deleted on the Connections page since the draft took it: connect again. */
|
|
42
|
+
removed: boolean;
|
|
43
|
+
/** The draft (or another draft holding it) created it, so discarding the draft deletes it. */
|
|
44
|
+
createdByDraft: boolean;
|
|
45
|
+
siteAnalysis: Record<string, unknown> | null;
|
|
46
|
+
publicCredentials: Record<string, string> | null;
|
|
47
|
+
lastTestedAt: string | null;
|
|
48
|
+
}
|
|
49
|
+
export interface PipelineDraftDiscovery {
|
|
50
|
+
id: string;
|
|
51
|
+
/** `pending` → `running` → `completed` | `failed`. Poll the draft to follow it. */
|
|
52
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
53
|
+
source: string;
|
|
54
|
+
errorMessage: string | null;
|
|
55
|
+
warnings: string[];
|
|
56
|
+
detectedPlugins: string[];
|
|
57
|
+
startedAt: string | null;
|
|
58
|
+
completedAt: string | null;
|
|
59
|
+
}
|
|
60
|
+
export interface PipelineDraftFieldMapping {
|
|
61
|
+
sourceField: string;
|
|
62
|
+
sourcePath: string;
|
|
63
|
+
targetField: string;
|
|
64
|
+
targetPath: string;
|
|
65
|
+
transform: string | null;
|
|
66
|
+
confidence: number;
|
|
67
|
+
enabled: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface PipelineDraftSchemaMap {
|
|
70
|
+
id: string;
|
|
71
|
+
entityType: string;
|
|
72
|
+
enabled: boolean;
|
|
73
|
+
confidence: number;
|
|
74
|
+
entityCount: number;
|
|
75
|
+
subCounts: Record<string, number> | null;
|
|
76
|
+
/** As stored: `{ sourceEntityType, fields: [{ name, path, type, sampleValues, … }], notes }`. */
|
|
77
|
+
sourceSchema: Record<string, unknown>;
|
|
78
|
+
/** As stored: `{ targetEntityType, allowedTargetEntityTypes? }`. */
|
|
79
|
+
targetSchema: Record<string, unknown>;
|
|
80
|
+
fieldMappings: PipelineDraftFieldMapping[];
|
|
81
|
+
}
|
|
82
|
+
/** What an importable entity type needs imported first, from the import writers themselves. */
|
|
83
|
+
export interface ImportDependency {
|
|
84
|
+
entityType: string;
|
|
85
|
+
dependsOn: string[];
|
|
86
|
+
/** It also depends on every type in the run starting with one of these (`cms_`). */
|
|
87
|
+
dependsOnPrefixes: string[];
|
|
88
|
+
}
|
|
89
|
+
/** An enabled entity type whose dependencies were discovered but switched off. */
|
|
90
|
+
export interface ImportDependencyWarning {
|
|
91
|
+
entityType: string;
|
|
92
|
+
missing: string[];
|
|
93
|
+
}
|
|
94
|
+
/** A draft and everything the set-up screen shows, read now. */
|
|
95
|
+
export interface PipelineDraft extends PipelineDraftSummary {
|
|
96
|
+
sourceUrl: string;
|
|
97
|
+
requestDelayMs: number;
|
|
98
|
+
/** As typed: a comma-separated list, parsed when the connection is created. */
|
|
99
|
+
legacyAssetHosts: string;
|
|
100
|
+
syncPolicy: PipelineSyncPolicy;
|
|
101
|
+
scheduleType: PipelineScheduleType;
|
|
102
|
+
cronExpression: string;
|
|
103
|
+
/** The schedule's zone; a new draft starts with the store's. */
|
|
104
|
+
timezone: string;
|
|
105
|
+
/**
|
|
106
|
+
* Whether the source's prices include tax. Until the merchant sets it (`sourcePricesIncludeTaxChosen`)
|
|
107
|
+
* it follows what the source reports when a connection is made, and before that the store's own
|
|
108
|
+
* setting.
|
|
109
|
+
*/
|
|
110
|
+
sourcePricesIncludeTax: boolean;
|
|
111
|
+
sourcePricesIncludeTaxChosen: boolean;
|
|
112
|
+
stockLocationId: string | null;
|
|
113
|
+
triggerType: PipelineTriggerType;
|
|
114
|
+
exportEntityTypes: string[];
|
|
115
|
+
triggerFilter: Record<string, string>;
|
|
116
|
+
connection: PipelineDraftConnection | null;
|
|
117
|
+
discovery: PipelineDraftDiscovery | null;
|
|
118
|
+
schemaMaps: PipelineDraftSchemaMap[];
|
|
119
|
+
dependencies: ImportDependency[];
|
|
120
|
+
dependencyWarnings: ImportDependencyWarning[];
|
|
121
|
+
/** The name the configure step would give it now, in the store's zone. */
|
|
122
|
+
suggestedName: string | null;
|
|
123
|
+
/** The store's business time zone; null when it could not be read just now. */
|
|
124
|
+
storeTimeZone: string | null;
|
|
125
|
+
}
|
|
126
|
+
/** A field change. `version` is the draft's current one. */
|
|
127
|
+
export interface UpdatePipelineDraftInput {
|
|
128
|
+
version: number;
|
|
129
|
+
direction?: PipelineDirection;
|
|
130
|
+
step?: PipelineDraftStep;
|
|
131
|
+
/** Starts the connection over, even for the same connector. */
|
|
132
|
+
connectorType?: string;
|
|
133
|
+
sourceUrl?: string;
|
|
134
|
+
requestDelayMs?: 50 | 100 | 200 | 300 | 500;
|
|
135
|
+
legacyAssetHosts?: string;
|
|
136
|
+
name?: string;
|
|
137
|
+
syncPolicy?: PipelineSyncPolicy;
|
|
138
|
+
scheduleType?: PipelineScheduleType;
|
|
139
|
+
/** A 5-part cron, or '' to clear it. */
|
|
140
|
+
cronExpression?: string;
|
|
141
|
+
timezone?: string;
|
|
142
|
+
sourcePricesIncludeTax?: boolean;
|
|
143
|
+
/** `null` clears it. */
|
|
144
|
+
stockLocationId?: string | null;
|
|
145
|
+
triggerType?: PipelineTriggerType;
|
|
146
|
+
exportEntityTypes?: string[];
|
|
147
|
+
triggerFilter?: Record<string, string>;
|
|
148
|
+
}
|
|
149
|
+
export interface UpdatePipelineDraftSchemaMapInput {
|
|
150
|
+
version: number;
|
|
151
|
+
enabled?: boolean;
|
|
152
|
+
fieldMappings?: PipelineDraftFieldMapping[];
|
|
153
|
+
/** Move a taxonomy to another target its schema map allows. */
|
|
154
|
+
targetEntityType?: string;
|
|
155
|
+
}
|
|
156
|
+
/** `commit`'s answer: the pipeline, and its first run when one was asked for. */
|
|
157
|
+
export interface CommittedPipelineDraft {
|
|
158
|
+
pipeline: {
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
direction: PipelineDirection;
|
|
162
|
+
connectionId: string;
|
|
163
|
+
discoveryId: string | null;
|
|
164
|
+
scheduleType: PipelineScheduleType;
|
|
165
|
+
isActive: boolean;
|
|
166
|
+
};
|
|
167
|
+
run: {
|
|
168
|
+
id: string;
|
|
169
|
+
status: string;
|
|
170
|
+
} | null;
|
|
171
|
+
/** The pipeline was saved but its first run did not start; start it from the pipeline. */
|
|
172
|
+
runError: {
|
|
173
|
+
code: string;
|
|
174
|
+
message: string;
|
|
175
|
+
} | null;
|
|
176
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes of `admin.integrations.pipelines` (headless spec §7 `pipelines.drafts`).
|
|
3
|
+
*
|
|
4
|
+
* Kept verbatim (stored data, never renamed): `triggerFilter`'s keys (reader field names such as
|
|
5
|
+
* `toState`), `siteAnalysis` and `publicCredentials` (the connector's own keys), and a schema
|
|
6
|
+
* map's `sourceSchema`, `targetSchema` and `subCounts`.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call } from '../types.js';
|
|
3
|
+
import { type JobHandle } from './index.js';
|
|
4
|
+
/**
|
|
5
|
+
* A bulk action run (`catalog.products.bulk`, `orders.bulk`): one call
|
|
6
|
+
* that acts on many records of the store as a job, each record through its single door and
|
|
7
|
+
* reported on its own. Read back through the Admin API's `bulkActionRun`.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* `QUEUED` → `RUNNING` → `SUCCEEDED` (every item ran and has its own outcome, a `FAILED` item
|
|
11
|
+
* included), or `FAILED` (the run stopped before every item had an outcome; `items` lists the ones
|
|
12
|
+
* it reached), or `CANCELLED` (the items after the cancel did not run; `items` lists every one
|
|
13
|
+
* the run reached, the one running when the cancel landed included). A run cancelled while an item
|
|
14
|
+
* ran stays `RUNNING` until that item has its outcome. A string on the wire: a newer engine may add
|
|
15
|
+
* a status.
|
|
16
|
+
*/
|
|
17
|
+
export type BulkActionRunStatus = 'QUEUED' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'CANCELLED';
|
|
18
|
+
/** A run nothing more will happen to. */
|
|
19
|
+
export declare const TERMINAL_BULK_ACTION_STATUSES: readonly string[];
|
|
20
|
+
/** One record's outcome. */
|
|
21
|
+
export interface BulkActionItem {
|
|
22
|
+
/** The record (a product id for `products.bulk`). */
|
|
23
|
+
id: string;
|
|
24
|
+
status: 'OK' | 'FAILED' | (string & {});
|
|
25
|
+
/**
|
|
26
|
+
* When `FAILED`: the single door's OWN code, the one a call of that door would have raised:
|
|
27
|
+
* `ENTITY_NOT_FOUND` (not in this store, another store's included), `SHARED_PRODUCT_NOT_ALLOWED`,
|
|
28
|
+
* `MANAGED_BY_ORGANIZATION`, `FIELD_GROUP_LOCKED`, `EXTERNAL_LINE_CARRIER_PROTECTED`,
|
|
29
|
+
* `PRODUCT_NOT_DELETED`, … Null when `OK`.
|
|
30
|
+
*/
|
|
31
|
+
code: string | null;
|
|
32
|
+
/** When `FAILED`: the door's sentence. Null when `OK`. */
|
|
33
|
+
message: string | null;
|
|
34
|
+
/** What the action made: the new product of a `CLONE`. Null otherwise. */
|
|
35
|
+
newId: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface BulkActionRun<Action extends string = string> {
|
|
38
|
+
/** The run's id: the receipt `bulk()` answered. */
|
|
39
|
+
id: string;
|
|
40
|
+
/** `products.bulk`. */
|
|
41
|
+
kind: string;
|
|
42
|
+
action: Action | (string & {});
|
|
43
|
+
status: BulkActionRunStatus | (string & {});
|
|
44
|
+
/** How many records the run was asked to act on. */
|
|
45
|
+
total: number;
|
|
46
|
+
/** How many of them have an outcome. */
|
|
47
|
+
done: number;
|
|
48
|
+
/** One outcome per record reached, in the order the records were named. */
|
|
49
|
+
items: BulkActionItem[];
|
|
50
|
+
/** Why the RUN stopped early (`FAILED`); each item keeps its own code. Null otherwise. */
|
|
51
|
+
failure: {
|
|
52
|
+
code: string;
|
|
53
|
+
message: string;
|
|
54
|
+
} | null;
|
|
55
|
+
}
|
|
56
|
+
export declare const BULK_ACTION_RUN_QUERY = "\n query BulkActionRun($runId: ID!) {\n bulkActionRun(runId: $runId) {\n id\n kind\n action\n status\n total\n done\n items {\n id\n status\n code\n message\n newId\n }\n failure {\n code\n message\n }\n }\n }\n";
|
|
57
|
+
/** One read of a run. A run of another store, or one that does not exist, is `NotFoundError`. */
|
|
58
|
+
export declare function readBulkActionRun<Action extends string>(transport: Transport, runId: string, options?: Call): Promise<BulkActionRun<Action>>;
|
|
59
|
+
/**
|
|
60
|
+
* The handle a bulk submit answers. `wait()` polls the run until it is terminal and resolves with
|
|
61
|
+
* it WHATEVER the ending (a run whose items all failed still `SUCCEEDED` as a run); it throws only
|
|
62
|
+
* when waiting itself cannot go on: `JOB_WAIT_TIMEOUT`, an aborted signal, or a read refused for
|
|
63
|
+
* a reason polling cannot fix.
|
|
64
|
+
*/
|
|
65
|
+
export declare function bulkActionHandle<Action extends string, Run extends RunProgress = BulkActionRun<Action>>(transport: Transport, runId: string, options?: Call,
|
|
66
|
+
/** How one read is made, when the kind selects more than the shared fields (orders). */
|
|
67
|
+
read?: (runId: string, call: Call) => Promise<Run>): JobHandle<Run>;
|
|
68
|
+
/** What waiting on a run reads of it, whatever its kind. */
|
|
69
|
+
interface RunProgress {
|
|
70
|
+
status: string;
|
|
71
|
+
done: number;
|
|
72
|
+
total: number;
|
|
73
|
+
}
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { TransportError } from '@sixtyninecommerce/core';
|
|
2
|
+
import { fieldOf } from '../catalog/types.js';
|
|
3
|
+
import { pollUntilTerminal } from './index.js';
|
|
4
|
+
/** A run nothing more will happen to. */
|
|
5
|
+
export const TERMINAL_BULK_ACTION_STATUSES = [
|
|
6
|
+
'SUCCEEDED',
|
|
7
|
+
'FAILED',
|
|
8
|
+
'CANCELLED',
|
|
9
|
+
];
|
|
10
|
+
export const BULK_ACTION_RUN_QUERY = /* GraphQL */ `
|
|
11
|
+
query BulkActionRun($runId: ID!) {
|
|
12
|
+
bulkActionRun(runId: $runId) {
|
|
13
|
+
id
|
|
14
|
+
kind
|
|
15
|
+
action
|
|
16
|
+
status
|
|
17
|
+
total
|
|
18
|
+
done
|
|
19
|
+
items {
|
|
20
|
+
id
|
|
21
|
+
status
|
|
22
|
+
code
|
|
23
|
+
message
|
|
24
|
+
newId
|
|
25
|
+
}
|
|
26
|
+
failure {
|
|
27
|
+
code
|
|
28
|
+
message
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
/** One read of a run. A run of another store, or one that does not exist, is `NotFoundError`. */
|
|
34
|
+
export function readBulkActionRun(transport, runId, options) {
|
|
35
|
+
return fieldOf(transport, BULK_ACTION_RUN_QUERY, 'bulkActionRun', { runId }, options);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The handle a bulk submit answers. `wait()` polls the run until it is terminal and resolves with
|
|
39
|
+
* it WHATEVER the ending (a run whose items all failed still `SUCCEEDED` as a run); it throws only
|
|
40
|
+
* when waiting itself cannot go on: `JOB_WAIT_TIMEOUT`, an aborted signal, or a read refused for
|
|
41
|
+
* a reason polling cannot fix.
|
|
42
|
+
*/
|
|
43
|
+
export function bulkActionHandle(transport, runId, options,
|
|
44
|
+
/** How one read is made, when the kind selects more than the shared fields (orders). */
|
|
45
|
+
read = (id, call) => readBulkActionRun(transport, id, call)) {
|
|
46
|
+
return {
|
|
47
|
+
runId,
|
|
48
|
+
wait(waitOptions) {
|
|
49
|
+
return pollUntilTerminal({
|
|
50
|
+
read: (signal) => read(runId, { ...options, ...(signal ? { signal } : {}) }),
|
|
51
|
+
isTerminal: (run) => TERMINAL_BULK_ACTION_STATUSES.includes(run.status),
|
|
52
|
+
onTimeout: (seen) => bulkWaitTimeout(runId, seen),
|
|
53
|
+
...waitOptions,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function bulkWaitTimeout(runId, run) {
|
|
59
|
+
const at = run
|
|
60
|
+
? `while it was ${run.status} (${String(run.done)} of ${String(run.total)} done)`
|
|
61
|
+
: 'without reading it successfully';
|
|
62
|
+
return new TransportError({
|
|
63
|
+
code: 'JOB_WAIT_TIMEOUT',
|
|
64
|
+
message: `Stopped waiting for bulk run ${runId} ${at}. The run may still be going: read it again with its runId to follow it.`,
|
|
65
|
+
status: 0,
|
|
66
|
+
service: 'vendure',
|
|
67
|
+
retryable: true,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -81,7 +81,7 @@ export interface LocationProfile {
|
|
|
81
81
|
*
|
|
82
82
|
* `address` is the one exception, because it writes through to the stock
|
|
83
83
|
* location's own field: omit it to leave that field alone, pass `null` to clear
|
|
84
|
-
* it.
|
|
84
|
+
* it. An address equal to the stored one writes nothing to that field.
|
|
85
85
|
*/
|
|
86
86
|
export interface UpsertLocationProfileInput {
|
|
87
87
|
stockLocationId: string;
|
|
@@ -107,7 +107,11 @@ export interface UpsertLocationProfileInput {
|
|
|
107
107
|
* cannot probe another store's ids; `LOCATION_CODE_TAKEN` (→ `ConflictError`);
|
|
108
108
|
* and `INVALID_LOCATION_CODE` / `INVALID_LOCATION_NAME` /
|
|
109
109
|
* `INVALID_LOCATION_PHONE` / `INVALID_TIMEZONE` / `INVALID_OPENING_HOURS` /
|
|
110
|
-
* `INVALID_ADDRESS` (→ `ValidationError`)
|
|
110
|
+
* `INVALID_ADDRESS` (→ `ValidationError`); and `LOCATION_NOT_ALLOWED`
|
|
111
|
+
* (→ `PermissionDeniedError`) when `upsert` changes or clears the `address` of a
|
|
112
|
+
* location a token or app installation restricted with `locationIds` does not
|
|
113
|
+
* hold. The address is the location's parcel sender. Sending the stored address
|
|
114
|
+
* back unchanged passes, and the profile's other fields are not restricted.
|
|
111
115
|
*
|
|
112
116
|
* `LOCATION_NOT_IN_CHANNEL` is NOT one of these: it belongs to the two places
|
|
113
117
|
* that take a location id from outside this surface — `apiTokens.create`/
|
package/dist/meta/index.d.ts
CHANGED
|
@@ -24,11 +24,21 @@ export interface MetaCatalogLabels {
|
|
|
24
24
|
subscriptionStatus: LabelMap;
|
|
25
25
|
quoteStatus: LabelMap;
|
|
26
26
|
settlementMethod: LabelMap;
|
|
27
|
+
/** What a RETAIL credit note did, keyed by its `kind`. */
|
|
27
28
|
creditNoteKind: LabelMap;
|
|
29
|
+
/**
|
|
30
|
+
* The same four kinds on the accounts-receivable ledger, in its own words:
|
|
31
|
+
* there `return` also covers a settled refund and a manual credit, so the
|
|
32
|
+
* retail "Return credited" would mislabel it. Pick the map by the note's
|
|
33
|
+
* ledger. Served by a platform from this release on.
|
|
34
|
+
*/
|
|
35
|
+
arCreditNoteKind: LabelMap;
|
|
28
36
|
auditService: LabelMap;
|
|
29
37
|
auditCategory: LabelMap;
|
|
30
38
|
auditEventOutcome: LabelMap;
|
|
31
39
|
auditCallOutcome: LabelMap;
|
|
40
|
+
/** Who sends a notification event's email: `platform` or `none` (`admin.tenant.notifications`). */
|
|
41
|
+
notificationSender: LabelMap;
|
|
32
42
|
/**
|
|
33
43
|
* A vocabulary added after this SDK release arrives camelised, with its map
|
|
34
44
|
* untouched.
|
|
@@ -59,10 +69,32 @@ export interface RoleTemplate {
|
|
|
59
69
|
permissions: string[];
|
|
60
70
|
}
|
|
61
71
|
export interface ApiTokenTemplate {
|
|
72
|
+
/**
|
|
73
|
+
* The preset's stable key, accepted by `admin.apiTokens.create({ templateKeys })`.
|
|
74
|
+
* Shipped presets: `content`, `forms`, `catalog` (catalogue CRUD — the spec's
|
|
75
|
+
* "catalog-writer"), `readonly`, `external-tracking`, `platform-events` (event
|
|
76
|
+
* feed, read-only), `audit`, `pos`, `order-entry` (place and recover orders,
|
|
77
|
+
* caller-priced lines, find or create the customer), `customers` (customer CRUD
|
|
78
|
+
* without delete or erasure), `stock` (stock reads, adjustments and transfers
|
|
79
|
+
* through `AdjustStock`; it cannot edit locations or their settings), `events` (the
|
|
80
|
+
* event feed plus managing webhook subscriptions: `ReadPlatformEvents` +
|
|
81
|
+
* `ManageEventSubscriptions`), `full`, `sandbox-full` (for CI against a
|
|
82
|
+
* sandbox store: Full access plus the event feed and subscriptions, the audit
|
|
83
|
+
* trail, POS, tracking and stock moves; never user, token or app management)
|
|
84
|
+
* and `custom`. Read the live list from `meta.catalog()`; this one is
|
|
85
|
+
* documentation.
|
|
86
|
+
*/
|
|
62
87
|
key: string;
|
|
63
88
|
label: string;
|
|
64
89
|
description: string;
|
|
65
90
|
permissions: string[];
|
|
91
|
+
/**
|
|
92
|
+
* `true` on a preset minted on a SANDBOX store only (`sandbox-full`);
|
|
93
|
+
* `apiTokens.create({ templateKeys })` refuses it elsewhere with
|
|
94
|
+
* `SANDBOX_ONLY_TEMPLATE`. A picker hides such a preset on a live store.
|
|
95
|
+
* Absent on every other preset, and on a platform older than this field.
|
|
96
|
+
*/
|
|
97
|
+
sandbox?: boolean;
|
|
66
98
|
}
|
|
67
99
|
export interface MetaCatalogPermissions {
|
|
68
100
|
/** Every permission name the Admin API registers. */
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `admin.orders.bulk`, `admin.orders.bulkRun` and `admin.orders.delete` (headless spec §7
|
|
3
|
+
* `orders.bulk`, plan W9-43; rulings G19, G28, G29).
|
|
4
|
+
*/
|
|
5
|
+
import { type Transport } from '@sixtyninecommerce/core';
|
|
6
|
+
import { type BulkActionItem, type BulkActionRun } from '../jobs/bulk-action-run.js';
|
|
7
|
+
import type { JobHandle } from '../jobs/index.js';
|
|
8
|
+
import type { Call } from '../types.js';
|
|
9
|
+
/** What each order of one bulk run gets. */
|
|
10
|
+
export type OrderBulkAction = 'TRANSITION' | 'CANCEL' | 'DELETE' | 'MARK_PAID';
|
|
11
|
+
export declare const ORDER_BULK_ACTIONS: readonly OrderBulkAction[];
|
|
12
|
+
/** The engine's bound on one bulk run (`MAX_BULK_ACTION_ITEMS`). Split a larger selection. */
|
|
13
|
+
export declare const MAX_BULK_ORDERS = 50;
|
|
14
|
+
/**
|
|
15
|
+
* The states a TRANSITION never names, each with its own action or door: `Cancelled` (CANCEL),
|
|
16
|
+
* `PaymentSettled` (MARK_PAID), `Modifying` (the order edit) and `AddingItems`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ORDER_BULK_TRANSITION_REFUSED: readonly string[];
|
|
19
|
+
export interface OrderBulkInput {
|
|
20
|
+
action: OrderBulkAction;
|
|
21
|
+
/** 1 to {@link MAX_BULK_ORDERS} orders of the store, each named once. */
|
|
22
|
+
orderIds: readonly string[];
|
|
23
|
+
/** TRANSITION only, and required there: the state each order moves to. */
|
|
24
|
+
toState?: string;
|
|
25
|
+
/** CANCEL only: the reason recorded on each cancelled order. */
|
|
26
|
+
reason?: string;
|
|
27
|
+
}
|
|
28
|
+
/** One payment a MARK_PAID item acted on. */
|
|
29
|
+
export interface OrderBulkCapture {
|
|
30
|
+
paymentId: string;
|
|
31
|
+
/** The payment's state after the capture: `Settled`, or what a decline left. */
|
|
32
|
+
state: string;
|
|
33
|
+
/**
|
|
34
|
+
* Why it was not captured, null when it was: `SETTLE_PAYMENT_ERROR` (declined; `message`
|
|
35
|
+
* quotes the provider), `PAYMENT_NOT_AUTHORIZED` (captured by someone else meanwhile),
|
|
36
|
+
* `PAYMENT_METHOD_UNAVAILABLE` (its method is switched off, not on this store, or no longer installed; nothing asked),
|
|
37
|
+
* `IDEMPOTENCY_IN_PROGRESS` (a capture under the same request may still run: check the order
|
|
38
|
+
* before trying again), `IDEMPOTENCY_OUTCOME_UNKNOWN` (the provider was asked and its answer
|
|
39
|
+
* was lost: reconcile with the provider, never retry blind), or a fault's code.
|
|
40
|
+
*/
|
|
41
|
+
code: string | null;
|
|
42
|
+
message: string | null;
|
|
43
|
+
}
|
|
44
|
+
/** One order's outcome. */
|
|
45
|
+
export interface OrderBulkItem extends BulkActionItem {
|
|
46
|
+
/**
|
|
47
|
+
* When `code` is `ORDER_ACTION_UNAVAILABLE`: why the order's own status (`orders.status`) did
|
|
48
|
+
* not offer the action, in that read's vocabulary (`STATE`, `INVOICE_LOCKED`, `SHOPPER_CART`,
|
|
49
|
+
* `HAS_RECORDS`, `UNITS_SHIPPED`, `ACTIVE_FULFILLMENT`, `NOTHING_TO_CANCEL`, …). Null otherwise.
|
|
50
|
+
*/
|
|
51
|
+
reasonCode: string | null;
|
|
52
|
+
/** MARK_PAID: each payment the order's item acted on, in order. Null for other actions. */
|
|
53
|
+
captured: OrderBulkCapture[] | null;
|
|
54
|
+
}
|
|
55
|
+
/** A bulk order run, as `wait()` and `bulkRun()` answer it. */
|
|
56
|
+
export type OrderBulkRun = Omit<BulkActionRun<OrderBulkAction>, 'items'> & {
|
|
57
|
+
items: OrderBulkItem[];
|
|
58
|
+
};
|
|
59
|
+
export declare const BULK_ORDER_ACTION_MUTATION = "\n mutation BulkOrderAction($input: BulkOrderActionInput!, $idempotencyKey: String) {\n bulkOrderAction(input: $input, idempotencyKey: $idempotencyKey) {\n runId\n }\n }\n";
|
|
60
|
+
/**
|
|
61
|
+
* The run read with the order fields. Its own document, so `catalog.products.bulkRun` keeps
|
|
62
|
+
* selecting only what an engine without the orders kind has.
|
|
63
|
+
*/
|
|
64
|
+
export declare const ORDER_BULK_RUN_QUERY = "\n query OrderBulkRun($runId: ID!) {\n bulkActionRun(runId: $runId) {\n id\n kind\n action\n status\n total\n done\n items {\n id\n status\n code\n message\n newId\n reasonCode\n captured {\n paymentId\n state\n code\n message\n }\n }\n failure {\n code\n message\n }\n }\n }\n";
|
|
65
|
+
export declare const DELETE_ORDER_MUTATION = "\n mutation DeleteOrder($orderId: ID!) {\n deleteOrder(orderId: $orderId) {\n result\n message\n }\n }\n";
|
|
66
|
+
/** One read of a bulk order run. A run of another store, or a missing one, is `NotFoundError`. */
|
|
67
|
+
export declare function readOrderBulkRun(transport: Transport, runId: string, options?: Call): Promise<OrderBulkRun>;
|
|
68
|
+
/** `orders.bulk`; see `OrdersModule.bulk`. */
|
|
69
|
+
export declare function bulkOrders(transport: Transport, input: OrderBulkInput, options?: Call): Promise<JobHandle<OrderBulkRun>>;
|
|
70
|
+
/**
|
|
71
|
+
* `orders.delete`; see `OrdersModule.delete`. The engine's `NOT_DELETED` is raised as every other
|
|
72
|
+
* `*_NOT_DELETED` refusal of this SDK is (`assertDeleted`): a `ConflictError` with the engine's own
|
|
73
|
+
* reason.
|
|
74
|
+
*/
|
|
75
|
+
export declare function deleteOrder(transport: Transport, orderId: string, options?: Call): Promise<void>;
|