@salsita-ai/contracts 0.0.0-stage → 0.49.0-develop.cbee856178
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/CHANGELOG.md +419 -0
- package/LICENSE +61 -0
- package/README.md +28 -2
- package/dist/api/access-level.d.ts +7 -0
- package/dist/api/access-level.js +1 -0
- package/dist/api/access-token.d.ts +6 -0
- package/dist/api/access-token.js +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +1 -0
- package/dist/api/session-role.d.ts +8 -0
- package/dist/api/session-role.js +1 -0
- package/dist/api/session-token.d.ts +22 -0
- package/dist/api/session-token.js +1 -0
- package/dist/assistant/browser-details-tool.d.ts +16 -0
- package/dist/assistant/browser-details-tool.js +1 -0
- package/dist/assistant/deployment-assistant.d.ts +84 -0
- package/dist/assistant/deployment-assistant.js +1 -0
- package/dist/assistant/graphql-tools.d.ts +120 -0
- package/dist/assistant/graphql-tools.js +1 -0
- package/dist/assistant/index.d.ts +6 -0
- package/dist/assistant/index.js +1 -0
- package/dist/assistant/message-metadata.d.ts +17 -0
- package/dist/assistant/message-metadata.js +1 -0
- package/dist/chat/api.d.ts +52 -0
- package/dist/chat/api.js +1 -0
- package/dist/chat/completions/messages.d.ts +3 -0
- package/dist/chat/completions/messages.js +1 -0
- package/dist/chat/completions/types.d.ts +28 -0
- package/dist/chat/completions/types.js +1 -0
- package/dist/chat/functions/augmentations.d.ts +3 -0
- package/dist/chat/functions/augmentations.js +1 -0
- package/dist/chat/functions/create.d.ts +5 -0
- package/dist/chat/functions/create.js +1 -0
- package/dist/chat/functions/process.d.ts +14 -0
- package/dist/chat/functions/process.js +1 -0
- package/dist/chat/functions/types.d.ts +21 -0
- package/dist/chat/functions/types.js +1 -0
- package/dist/chat/functions/validate.d.ts +1 -0
- package/dist/chat/functions/validate.js +2 -0
- package/dist/chat/index.d.ts +10 -0
- package/dist/chat/index.js +1 -0
- package/dist/chat/utils/types.d.ts +1 -0
- package/dist/chat/utils/types.js +1 -0
- package/dist/clerk/clerk-backend-api-client.d.ts +129 -0
- package/dist/clerk/clerk-backend-api-client.js +1 -0
- package/dist/clerk/clerk-backend-api-types.d.ts +740 -0
- package/dist/clerk/clerk-backend-api-types.js +1 -0
- package/dist/clerk/clerk-session-token.d.ts +28 -0
- package/dist/clerk/clerk-session-token.js +1 -0
- package/dist/clerk/clerk-token-service.d.ts +15 -0
- package/dist/clerk/clerk-token-service.js +1 -0
- package/dist/clerk/index.d.ts +4 -0
- package/dist/clerk/index.js +1 -0
- package/dist/domain/deployments/ai-image-domain.d.ts +10 -0
- package/dist/domain/deployments/ai-image-domain.js +1 -0
- package/dist/domain/deployments/api-token-domain.d.ts +8 -0
- package/dist/domain/deployments/api-token-domain.js +1 -0
- package/dist/domain/deployments/configuration-schema-domain.d.ts +22 -0
- package/dist/domain/deployments/configuration-schema-domain.js +1 -0
- package/dist/domain/deployments/customer-domain.d.ts +69 -0
- package/dist/domain/deployments/customer-domain.js +1 -0
- package/dist/domain/deployments/deployment-build-domain.d.ts +78 -0
- package/dist/domain/deployments/deployment-build-domain.js +1 -0
- package/dist/domain/deployments/deployment-domain.d.ts +126 -0
- package/dist/domain/deployments/deployment-domain.js +1 -0
- package/dist/domain/deployments/embedding-domain.d.ts +9 -0
- package/dist/domain/deployments/embedding-domain.js +1 -0
- package/dist/domain/deployments/environment-domain.d.ts +107 -0
- package/dist/domain/deployments/environment-domain.js +1 -0
- package/dist/domain/deployments/image-render-domain.d.ts +22 -0
- package/dist/domain/deployments/image-render-domain.js +1 -0
- package/dist/domain/deployments/index.d.ts +14 -0
- package/dist/domain/deployments/index.js +1 -0
- package/dist/domain/deployments/oauth-connection-domain.d.ts +62 -0
- package/dist/domain/deployments/oauth-connection-domain.js +1 -0
- package/dist/domain/deployments/oauth-provider-domain.d.ts +23 -0
- package/dist/domain/deployments/oauth-provider-domain.js +1 -0
- package/dist/domain/deployments/project-domain.d.ts +26 -0
- package/dist/domain/deployments/project-domain.js +1 -0
- package/dist/domain/deployments/sdk-builder-setup-domain.d.ts +13 -0
- package/dist/domain/deployments/sdk-builder-setup-domain.js +1 -0
- package/dist/domain/deployments/session-domain.d.ts +20 -0
- package/dist/domain/deployments/session-domain.js +1 -0
- package/dist/domain/feedback/feedback-domain.d.ts +55 -0
- package/dist/domain/feedback/feedback-domain.js +1 -0
- package/dist/domain/feedback/index.d.ts +1 -0
- package/dist/domain/feedback/index.js +1 -0
- package/dist/domain/index.d.ts +3 -0
- package/dist/domain/index.js +1 -0
- package/dist/domain/product-configurations/configurations-domain.d.ts +113 -0
- package/dist/domain/product-configurations/configurations-domain.js +1 -0
- package/dist/domain/product-configurations/index.d.ts +1 -0
- package/dist/domain/product-configurations/index.js +1 -0
- package/dist/webhook/core/index.d.ts +3 -0
- package/dist/webhook/core/index.js +1 -0
- package/dist/webhook/core/task-resource.d.ts +80 -0
- package/dist/webhook/core/task-resource.js +1 -0
- package/dist/webhook/core/task-type.d.ts +18 -0
- package/dist/webhook/core/task-type.js +1 -0
- package/dist/webhook/core/template.d.ts +65 -0
- package/dist/webhook/core/template.js +1 -0
- package/dist/webhook/empty-xlsx.d.ts +10 -0
- package/dist/webhook/empty-xlsx.js +1 -0
- package/dist/webhook/excel-workbook-client.d.ts +78 -0
- package/dist/webhook/excel-workbook-client.js +1 -0
- package/dist/webhook/google-sheets-client.d.ts +23 -0
- package/dist/webhook/google-sheets-client.js +1 -0
- package/dist/webhook/implementation/index.d.ts +4 -0
- package/dist/webhook/implementation/index.js +1 -0
- package/dist/webhook/implementation/webhook-api-types.d.ts +302 -0
- package/dist/webhook/implementation/webhook-api-types.js +1 -0
- package/dist/webhook/implementation/webhook-client.d.ts +85 -0
- package/dist/webhook/implementation/webhook-client.js +1 -0
- package/dist/webhook/implementation/webhook-routing.d.ts +30 -0
- package/dist/webhook/implementation/webhook-routing.js +1 -0
- package/dist/webhook/implementation/webhook-tunnel-types.d.ts +114 -0
- package/dist/webhook/implementation/webhook-tunnel-types.js +1 -0
- package/dist/webhook/index.d.ts +7 -0
- package/dist/webhook/index.js +1 -0
- package/dist/webhook/spreadsheet-adapter-factory.d.ts +10 -0
- package/dist/webhook/spreadsheet-adapter-factory.js +1 -0
- package/dist/webhook/spreadsheet-adapter.d.ts +94 -0
- package/dist/webhook/spreadsheet-adapter.js +1 -0
- package/dist/webhook/tasks/call-lambda-back-task.d.ts +22 -0
- package/dist/webhook/tasks/call-lambda-back-task.js +1 -0
- package/dist/webhook/tasks/edit-google-spreadsheet-task.d.ts +48 -0
- package/dist/webhook/tasks/edit-google-spreadsheet-task.js +1 -0
- package/dist/webhook/tasks/finalize-task.d.ts +184 -0
- package/dist/webhook/tasks/finalize-task.js +1 -0
- package/dist/webhook/tasks/generate-configuration-link-task.d.ts +56 -0
- package/dist/webhook/tasks/generate-configuration-link-task.js +1 -0
- package/dist/webhook/tasks/generate-csv-task.d.ts +30 -0
- package/dist/webhook/tasks/generate-csv-task.js +1 -0
- package/dist/webhook/tasks/generate-images-task.d.ts +404 -0
- package/dist/webhook/tasks/generate-images-task.js +1 -0
- package/dist/webhook/tasks/generate-pdf-task.d.ts +188 -0
- package/dist/webhook/tasks/generate-pdf-task.js +1 -0
- package/dist/webhook/tasks/index.d.ts +13 -0
- package/dist/webhook/tasks/index.js +1 -0
- package/dist/webhook/tasks/publish-revision-chunks-staged-task.d.ts +73 -0
- package/dist/webhook/tasks/publish-revision-chunks-staged-task.js +1 -0
- package/dist/webhook/tasks/publish-revision-chunks-task.d.ts +76 -0
- package/dist/webhook/tasks/publish-revision-chunks-task.js +1 -0
- package/dist/webhook/tasks/publish-revision-task.d.ts +38 -0
- package/dist/webhook/tasks/publish-revision-task.js +1 -0
- package/dist/webhook/tasks/send-email-task.d.ts +129 -0
- package/dist/webhook/tasks/send-email-task.js +1 -0
- package/dist/webhook/tasks/send-http-task.d.ts +27 -0
- package/dist/webhook/tasks/send-http-task.js +1 -0
- package/dist/webhook/tasks/woocommerce-add-to-cart-task.d.ts +91 -0
- package/dist/webhook/tasks/woocommerce-add-to-cart-task.js +1 -0
- package/dist/webhook/webhook-payload.d.ts +56 -0
- package/dist/webhook/webhook-payload.js +1 -0
- package/package.json +84 -3
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A webhook invocation waiting for a connected development client. */
|
|
3
|
+
export declare const TunneledWebhookRequest: z.ZodObject<{
|
|
4
|
+
requestId: z.ZodString;
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
method: z.ZodString;
|
|
7
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
8
|
+
body: z.ZodNullable<z.ZodString>;
|
|
9
|
+
deadline: z.ZodNumber;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
requestId: string;
|
|
12
|
+
url: string;
|
|
13
|
+
method: string;
|
|
14
|
+
headers: Record<string, string>;
|
|
15
|
+
body: string | null;
|
|
16
|
+
deadline: number;
|
|
17
|
+
}, {
|
|
18
|
+
requestId: string;
|
|
19
|
+
url: string;
|
|
20
|
+
method: string;
|
|
21
|
+
headers: Record<string, string>;
|
|
22
|
+
body: string | null;
|
|
23
|
+
deadline: number;
|
|
24
|
+
}>;
|
|
25
|
+
export type TunneledWebhookRequest = z.infer<typeof TunneledWebhookRequest>;
|
|
26
|
+
/** The development client's response to a tunneled webhook invocation. */
|
|
27
|
+
export declare const TunneledWebhookResponse: z.ZodObject<{
|
|
28
|
+
status: z.ZodNumber;
|
|
29
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
30
|
+
body: z.ZodString;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
status: number;
|
|
33
|
+
headers?: Record<string, string> | undefined;
|
|
34
|
+
body: string;
|
|
35
|
+
}, {
|
|
36
|
+
status: number;
|
|
37
|
+
headers?: Record<string, string> | undefined;
|
|
38
|
+
body: string;
|
|
39
|
+
}>;
|
|
40
|
+
export type TunneledWebhookResponse = z.infer<typeof TunneledWebhookResponse>;
|
|
41
|
+
/** Payload used to claim a development deployment and wait for its next webhook request. */
|
|
42
|
+
export declare const WebhookTunnelPollRequest: z.ZodObject<{
|
|
43
|
+
sessionId: z.ZodString;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
sessionId: string;
|
|
46
|
+
}, {
|
|
47
|
+
sessionId: string;
|
|
48
|
+
}>;
|
|
49
|
+
export type WebhookTunnelPollRequest = z.infer<typeof WebhookTunnelPollRequest>;
|
|
50
|
+
/** Result of waiting for the next tunneled webhook request. */
|
|
51
|
+
export declare const WebhookTunnelPollResponse: z.ZodObject<{
|
|
52
|
+
request: z.ZodNullable<z.ZodObject<{
|
|
53
|
+
requestId: z.ZodString;
|
|
54
|
+
url: z.ZodString;
|
|
55
|
+
method: z.ZodString;
|
|
56
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
57
|
+
body: z.ZodNullable<z.ZodString>;
|
|
58
|
+
deadline: z.ZodNumber;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
requestId: string;
|
|
61
|
+
url: string;
|
|
62
|
+
method: string;
|
|
63
|
+
headers: Record<string, string>;
|
|
64
|
+
body: string | null;
|
|
65
|
+
deadline: number;
|
|
66
|
+
}, {
|
|
67
|
+
requestId: string;
|
|
68
|
+
url: string;
|
|
69
|
+
method: string;
|
|
70
|
+
headers: Record<string, string>;
|
|
71
|
+
body: string | null;
|
|
72
|
+
deadline: number;
|
|
73
|
+
}>>;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
request: {
|
|
76
|
+
requestId: string;
|
|
77
|
+
url: string;
|
|
78
|
+
method: string;
|
|
79
|
+
headers: Record<string, string>;
|
|
80
|
+
body: string | null;
|
|
81
|
+
deadline: number;
|
|
82
|
+
} | null;
|
|
83
|
+
}, {
|
|
84
|
+
request: {
|
|
85
|
+
requestId: string;
|
|
86
|
+
url: string;
|
|
87
|
+
method: string;
|
|
88
|
+
headers: Record<string, string>;
|
|
89
|
+
body: string | null;
|
|
90
|
+
deadline: number;
|
|
91
|
+
} | null;
|
|
92
|
+
}>;
|
|
93
|
+
export type WebhookTunnelPollResponse = z.infer<typeof WebhookTunnelPollResponse>;
|
|
94
|
+
/** Payload used by a development client to answer a tunneled webhook request. */
|
|
95
|
+
export declare const WebhookTunnelRespondRequest: z.ZodObject<{
|
|
96
|
+
sessionId: z.ZodString;
|
|
97
|
+
requestId: z.ZodString;
|
|
98
|
+
status: z.ZodNumber;
|
|
99
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
100
|
+
body: z.ZodString;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
sessionId: string;
|
|
103
|
+
requestId: string;
|
|
104
|
+
status: number;
|
|
105
|
+
headers?: Record<string, string> | undefined;
|
|
106
|
+
body: string;
|
|
107
|
+
}, {
|
|
108
|
+
sessionId: string;
|
|
109
|
+
requestId: string;
|
|
110
|
+
status: number;
|
|
111
|
+
headers?: Record<string, string> | undefined;
|
|
112
|
+
body: string;
|
|
113
|
+
}>;
|
|
114
|
+
export type WebhookTunnelRespondRequest = z.infer<typeof WebhookTunnelRespondRequest>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";export const TunneledWebhookRequest=e.object({requestId:e.string(),url:e.string(),method:e.string(),headers:e.record(e.string()),body:e.string().nullable(),deadline:e.number()});export const TunneledWebhookResponse=e.object({status:e.number().int(),headers:e.record(e.string()).optional(),body:e.string()});export const WebhookTunnelPollRequest=e.object({sessionId:e.string()});export const WebhookTunnelPollResponse=e.object({request:TunneledWebhookRequest.nullable()});export const WebhookTunnelRespondRequest=e.object({sessionId:e.string(),requestId:e.string(),status:e.number().int(),headers:e.record(e.string()).optional(),body:e.string()});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './core/index.js';
|
|
2
|
+
export * from './tasks/index.js';
|
|
3
|
+
export * from './implementation/index.js';
|
|
4
|
+
export * from './spreadsheet-adapter.js';
|
|
5
|
+
export * from './spreadsheet-adapter-factory.js';
|
|
6
|
+
export * from './google-sheets-client.js';
|
|
7
|
+
export * from './excel-workbook-client.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./core/index.js";export*from"./tasks/index.js";export*from"./implementation/index.js";export*from"./spreadsheet-adapter.js";export*from"./spreadsheet-adapter-factory.js";export*from"./google-sheets-client.js";export*from"./excel-workbook-client.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SpreadsheetAdapter } from './spreadsheet-adapter.js';
|
|
2
|
+
/**
|
|
3
|
+
* Providers supported by the `SpreadsheetAdapter` factory. This is *not* the
|
|
4
|
+
* same as `OAuthConnectionProvider` — that type only covers providers that
|
|
5
|
+
* use per-user OAuth (Google). Microsoft uses app-only auth and isn't an
|
|
6
|
+
* "OAuth connection", but it *does* have a SpreadsheetAdapter implementation.
|
|
7
|
+
*/
|
|
8
|
+
export type SpreadsheetProvider = 'google' | 'microsoft';
|
|
9
|
+
export declare const asOAuthConnectionProvider: (provider: string) => SpreadsheetProvider;
|
|
10
|
+
export declare const getSpreadsheetAdapter: (provider: SpreadsheetProvider | string) => SpreadsheetAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{match as e}from"ts-pattern";import{excelSpreadsheetAdapter as o}from"./excel-workbook-client.js";import{googleSpreadsheetAdapter as t}from"./google-sheets-client.js";export const asOAuthConnectionProvider=e=>{if("google"!==e&&"microsoft"!==e)throw Error(`Unknown spreadsheet provider "${e}". Expected 'google' or 'microsoft'. ConnectedDataConfig.provider is typed as string at the schema layer; runtime values must be one of the supported SpreadsheetProvider literals.`);return e};export const getSpreadsheetAdapter=r=>e(asOAuthConnectionProvider(r)).with("google",()=>t).with("microsoft",()=>o).exhaustive();
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { OAuthConnectionProvider } from '../domain/index.js';
|
|
2
|
+
export type CellValue = string | number | boolean;
|
|
3
|
+
export interface ColumnMeta {
|
|
4
|
+
readonly type: 'string' | 'number' | 'integer' | 'boolean';
|
|
5
|
+
readonly enum?: ReadonlyArray<string | number>;
|
|
6
|
+
readonly array?: true;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Discriminated kinds of failure that can come back from a spreadsheet
|
|
10
|
+
* provider. Both adapters map provider-specific HTTP statuses onto this
|
|
11
|
+
* union so UI code can branch on `kind` instead of parsing message strings.
|
|
12
|
+
*/
|
|
13
|
+
export type SpreadsheetAdapterErrorKind = 'auth' | 'forbidden' | 'not-found' | 'rate-limit' | 'locked' | 'unknown';
|
|
14
|
+
/**
|
|
15
|
+
* Error thrown by every SpreadsheetAdapter implementation. The full
|
|
16
|
+
* provider-specific message is preserved in `.message`; callers that want
|
|
17
|
+
* to react to *kinds* of failure (re-auth prompt, retry, etc.) should
|
|
18
|
+
* branch on `.kind` instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare class SpreadsheetAdapterError extends Error {
|
|
21
|
+
readonly kind: SpreadsheetAdapterErrorKind;
|
|
22
|
+
readonly provider: 'google' | 'microsoft';
|
|
23
|
+
readonly status: number;
|
|
24
|
+
readonly action: string;
|
|
25
|
+
readonly bodyExcerpt: string;
|
|
26
|
+
constructor(props: {
|
|
27
|
+
readonly kind: SpreadsheetAdapterErrorKind;
|
|
28
|
+
readonly provider: 'google' | 'microsoft';
|
|
29
|
+
readonly status: number;
|
|
30
|
+
readonly action: string;
|
|
31
|
+
readonly bodyExcerpt: string;
|
|
32
|
+
readonly message: string;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Normalizes a CellValue for *writing* based on the column type. Used by
|
|
37
|
+
* both adapters so coercion semantics match across providers:
|
|
38
|
+
* - boolean columns: string 'true'/'false' (any case) → real boolean
|
|
39
|
+
* - number/integer columns: numeric string → number (empty string stays "")
|
|
40
|
+
* - string columns / no meta: value passed through unchanged
|
|
41
|
+
*
|
|
42
|
+
* Non-numeric strings written into a number column stay as the original
|
|
43
|
+
* string — callers can decide whether to validate before writing.
|
|
44
|
+
*/
|
|
45
|
+
export declare const normalizeCellOnWrite: (value: CellValue, col?: ColumnMeta) => CellValue;
|
|
46
|
+
export interface SheetTabData {
|
|
47
|
+
readonly headers: readonly string[];
|
|
48
|
+
readonly rows: ReadonlyArray<readonly string[]>;
|
|
49
|
+
}
|
|
50
|
+
export interface SpreadsheetMeta {
|
|
51
|
+
readonly tabs: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
export interface LegendTabData {
|
|
54
|
+
readonly tabName: string;
|
|
55
|
+
readonly rows: ReadonlyArray<readonly [string, string, string, string]>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Provider-agnostic file reference. driveId is null for Google (single-drive
|
|
59
|
+
* model), required for Microsoft Graph (drive + item id pair). Mirrors the
|
|
60
|
+
* shape stored on `ConnectedDataConfig`.
|
|
61
|
+
*/
|
|
62
|
+
export interface SpreadsheetFileRef {
|
|
63
|
+
readonly fileId: string;
|
|
64
|
+
readonly driveId: string | null;
|
|
65
|
+
}
|
|
66
|
+
export interface CreateSpreadsheetResult {
|
|
67
|
+
readonly fileId: string;
|
|
68
|
+
readonly driveId: string | null;
|
|
69
|
+
readonly title: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Provider-specific location context for createWorkbook. Google ignores it
|
|
73
|
+
* (creates in the connected user's Drive). Microsoft requires `siteId` so the
|
|
74
|
+
* file is created in the project's configured SharePoint site's default
|
|
75
|
+
* document library.
|
|
76
|
+
*/
|
|
77
|
+
export interface CreateWorkbookLocation {
|
|
78
|
+
readonly siteId?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface SpreadsheetAdapter {
|
|
81
|
+
fetchMeta: (accessToken: string, ref: SpreadsheetFileRef) => Promise<SpreadsheetMeta>;
|
|
82
|
+
fetchTabHeaders: (accessToken: string, ref: SpreadsheetFileRef, tabName: string) => Promise<readonly string[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Fetches all data from the given tabs/worksheets.
|
|
85
|
+
* `headerRowIndex` (0-based) selects which row to treat as headers; rows
|
|
86
|
+
* above it are dropped, rows after it become data. `null`/`undefined`
|
|
87
|
+
* defaults to row 0 — preserves prior behavior.
|
|
88
|
+
*/
|
|
89
|
+
fetchData: (accessToken: string, ref: SpreadsheetFileRef, tabNames: readonly string[], headerRowIndex?: number | null) => Promise<readonly SheetTabData[]>;
|
|
90
|
+
createWorkbook: (accessToken: string, title: string, headers: readonly string[], values?: ReadonlyArray<readonly CellValue[]>, columns?: readonly ColumnMeta[], dataTabName?: string, legendTab?: LegendTabData, location?: CreateWorkbookLocation) => Promise<CreateSpreadsheetResult>;
|
|
91
|
+
resetData: (accessToken: string, ref: SpreadsheetFileRef, tabNames: readonly string[], headers: readonly string[], values: ReadonlyArray<readonly CellValue[]>, columns?: readonly ColumnMeta[], legendTab?: LegendTabData) => Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
export declare const isRowEmpty: (row: readonly CellValue[]) => boolean;
|
|
94
|
+
export type SpreadsheetAdapterFactory = (provider: OAuthConnectionProvider) => SpreadsheetAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class SpreadsheetAdapterError extends Error{kind;provider;status;action;bodyExcerpt;constructor(e){super(e.message),this.name="SpreadsheetAdapterError",this.kind=e.kind,this.provider=e.provider,this.status=e.status,this.action=e.action,this.bodyExcerpt=e.bodyExcerpt}}export const normalizeCellOnWrite=(e,r)=>{if("string"!=typeof e)return e;if(r?.type==="boolean"){let r=e.toLowerCase();return"true"===r||"false"!==r&&e}if(r?.type==="number"||r?.type==="integer"){if(""===e)return e;let r=Number(e);if(!isNaN(r))return r}return e};export const isRowEmpty=e=>e.every(e=>{let r=String(e).trim().toUpperCase();return""===r||"FALSE"===r||"0"===r});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ValueOf } from '@salsita-ai/common/utils';
|
|
3
|
+
import { type FinalizeTaskResource, TaskType } from '../core/index.js';
|
|
4
|
+
export declare const CallLambdaBackResourceType: {
|
|
5
|
+
readonly Link: 'Link';
|
|
6
|
+
};
|
|
7
|
+
export type CallLambdaBackResourceType = ValueOf<typeof CallLambdaBackResourceType>;
|
|
8
|
+
export interface CallLambdaBackResource {
|
|
9
|
+
/**
|
|
10
|
+
* Lambda callback supports only link type. Embedding data into the task result would mean
|
|
11
|
+
* using multiplart/form-data, which would make things more complicated.
|
|
12
|
+
*/
|
|
13
|
+
embeddingType: CallLambdaBackResourceType;
|
|
14
|
+
}
|
|
15
|
+
export declare const CallLambdaBackResource: z.ZodType<CallLambdaBackResource>;
|
|
16
|
+
export interface CallLambdaBackTask<REPLAY_DATA extends Record<string, unknown>, RESOURCE extends string> {
|
|
17
|
+
type: typeof TaskType.CallLambdaBack;
|
|
18
|
+
replayData: REPLAY_DATA;
|
|
19
|
+
resources: Partial<Record<RESOURCE, CallLambdaBackResource>>;
|
|
20
|
+
}
|
|
21
|
+
export declare const CallLambdaBackTask: z.ZodType<CallLambdaBackTask<Record<string, unknown>, string>>;
|
|
22
|
+
export declare const validateCallLambdaBackTask: (task: CallLambdaBackTask<Record<string, unknown>, string>, resources: FinalizeTaskResource[]) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";import{TaskType as a}from"../core/index.js";export const CallLambdaBackResourceType={Link:"Link"};export const CallLambdaBackResource=e.object({embeddingType:e.literal(CallLambdaBackResourceType.Link)});export const CallLambdaBackTask=e.object({type:e.literal(a.CallLambdaBack),replayData:e.record(e.unknown()),resources:e.record(CallLambdaBackResource)});export const validateCallLambdaBackTask=(e,a)=>{for(let[r,o]of Object.entries(e.resources)){if(o?.embeddingType!==CallLambdaBackResourceType.Link)throw Error(`Resource ${r} has unsupported embedding type ${o?.embeddingType}`);if(null==a.find(e=>e.name===r))throw Error(`Resource ${r} not found in declared resources!`)}};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ValueOf } from '@salsita-ai/common/utils';
|
|
3
|
+
import { TaskResourceType, TaskType } from '../core/index.js';
|
|
4
|
+
export declare const GoogleSpreadsheetEditMode: {
|
|
5
|
+
/**
|
|
6
|
+
* Append a row or rows
|
|
7
|
+
*/
|
|
8
|
+
readonly Append: 'append';
|
|
9
|
+
/**
|
|
10
|
+
* Overwrite the range
|
|
11
|
+
*/
|
|
12
|
+
readonly Overwrite: 'overwrite';
|
|
13
|
+
};
|
|
14
|
+
export type GoogleSpreadsheetEditMode = ValueOf<typeof GoogleSpreadsheetEditMode>;
|
|
15
|
+
export interface GoogleSpreadsheetReference {
|
|
16
|
+
type: typeof TaskResourceType.ConfigurationLink;
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const GoogleSpreadsheetReference: z.ZodType<GoogleSpreadsheetReference>;
|
|
20
|
+
export type GoogleSpreadsheetCellValue = string | number | boolean | GoogleSpreadsheetReference;
|
|
21
|
+
export declare const GoogleSpreadsheetCellValue: z.ZodType<GoogleSpreadsheetCellValue>;
|
|
22
|
+
export interface GoogleSpreadsheetEdit {
|
|
23
|
+
/**
|
|
24
|
+
* Ranges of cells to edit
|
|
25
|
+
*/
|
|
26
|
+
ranges: Record<string, GoogleSpreadsheetCellValue[][]>;
|
|
27
|
+
/**
|
|
28
|
+
* Edit mode
|
|
29
|
+
*/
|
|
30
|
+
mode: GoogleSpreadsheetEditMode;
|
|
31
|
+
}
|
|
32
|
+
export declare const GoogleSpreadsheetEdit: z.ZodType<GoogleSpreadsheetEdit>;
|
|
33
|
+
export interface EditGoogleSpreadsheetTask {
|
|
34
|
+
type: typeof TaskType.EditGoogleSpreadsheet;
|
|
35
|
+
/**
|
|
36
|
+
* Service account credentials
|
|
37
|
+
*/
|
|
38
|
+
credentials: Record<string, string>;
|
|
39
|
+
/**
|
|
40
|
+
* The ID of the spreadsheet
|
|
41
|
+
*/
|
|
42
|
+
spreadsheetId: string;
|
|
43
|
+
/**
|
|
44
|
+
* Any edits to be made to the spreadsheet
|
|
45
|
+
*/
|
|
46
|
+
edits: GoogleSpreadsheetEdit[];
|
|
47
|
+
}
|
|
48
|
+
export declare const EditGoogleSpreadsheetTask: z.ZodType<EditGoogleSpreadsheetTask>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";import{TaskResourceType as o,TaskType as r}from"../core/index.js";export const GoogleSpreadsheetEditMode={Append:"append",Overwrite:"overwrite"};export const GoogleSpreadsheetReference=e.object({type:e.literal(o.ConfigurationLink),name:e.string()});export const GoogleSpreadsheetCellValue=e.union([e.string(),e.number(),e.boolean(),GoogleSpreadsheetReference]);export const GoogleSpreadsheetEdit=e.object({ranges:e.record(e.array(e.array(GoogleSpreadsheetCellValue))),mode:e.union([e.literal(GoogleSpreadsheetEditMode.Append),e.literal(GoogleSpreadsheetEditMode.Overwrite)])});export const EditGoogleSpreadsheetTask=e.object({type:e.literal(r.EditGoogleSpreadsheet),credentials:e.record(e.string()),spreadsheetId:e.string(),edits:e.array(GoogleSpreadsheetEdit)});
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FinalizeTaskResource } from '../core/task-resource.js';
|
|
3
|
+
import { CallLambdaBackTask } from './call-lambda-back-task.js';
|
|
4
|
+
import { EditGoogleSpreadsheetTask } from './edit-google-spreadsheet-task.js';
|
|
5
|
+
import { GenerateConfigurationLinkTask } from './generate-configuration-link-task.js';
|
|
6
|
+
import { GenerateCsvTask } from './generate-csv-task.js';
|
|
7
|
+
import { GenerateImagesTask } from './generate-images-task.js';
|
|
8
|
+
import { GeneratePdfTask, GenerateStaticPdfTask } from './generate-pdf-task.js';
|
|
9
|
+
import { PublishRevisionChunksStagedTask } from './publish-revision-chunks-staged-task.js';
|
|
10
|
+
import { PublishRevisionChunksTask } from './publish-revision-chunks-task.js';
|
|
11
|
+
import { PublishRevisionTask } from './publish-revision-task.js';
|
|
12
|
+
import { SendEmailTask, SendStaticEmailTask } from './send-email-task.js';
|
|
13
|
+
import { SendHttpRequestTask } from './send-http-task.js';
|
|
14
|
+
import { WooCommerceAddToCartTask } from './woocommerce-add-to-cart-task.js';
|
|
15
|
+
export type WebhookFinalizeTask = GenerateConfigurationLinkTask | SendEmailTask | SendStaticEmailTask | GenerateImagesTask | GeneratePdfTask | GenerateStaticPdfTask | GenerateCsvTask | SendHttpRequestTask | WooCommerceAddToCartTask | EditGoogleSpreadsheetTask | PublishRevisionTask | PublishRevisionChunksTask | PublishRevisionChunksStagedTask | CallLambdaBackTask<Record<string, unknown>, string>;
|
|
16
|
+
export interface WebhookFinalizeTaskConfiguration {
|
|
17
|
+
/**
|
|
18
|
+
* Version of the data used to check compatibility of the server and deployed webhooks, BUMP IT UP WHEN introducing breaking CHANGING THE SCHEMA!!!!
|
|
19
|
+
*/
|
|
20
|
+
dataVersion: 1;
|
|
21
|
+
/**
|
|
22
|
+
* The tasks to be executed as part of the finalize configuration
|
|
23
|
+
* They are executed in order and can reuse the resources generated by the previous tasks
|
|
24
|
+
*
|
|
25
|
+
* GenerateConfigurationLinkTask / PublishRevisionTask => GenerateImages => GenerateCsv => GeneratePdf => SendEmail => SendHttpRequest => WooCommerceAddToCart => EditGoogleSpreadsheet
|
|
26
|
+
*/
|
|
27
|
+
tasks: WebhookFinalizeTask[];
|
|
28
|
+
/**
|
|
29
|
+
* The resources that are generated as part of the finalize configuration, these are validated against the tasks
|
|
30
|
+
*/
|
|
31
|
+
resources: FinalizeTaskResource[];
|
|
32
|
+
}
|
|
33
|
+
export declare const WebhookFinalizeTaskConfiguration: z.ZodObject<{
|
|
34
|
+
dataVersion: z.ZodLiteral<1>;
|
|
35
|
+
tasks: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
36
|
+
type: z.ZodLiteral<"GenerateConfigurationLink">;
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
frontendUrl: z.ZodEffects<z.ZodString, import("../../domain/index.js").FrontendUrl, string>;
|
|
39
|
+
expiration: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
access: z.ZodUnion<[z.ZodLiteral<"o">, z.ZodLiteral<"rr">, z.ZodLiteral<"r">]>;
|
|
41
|
+
configurationId: z.ZodEffects<z.ZodString, import("../../domain/index.js").ConfigurationId, string>;
|
|
42
|
+
revisionId: z.ZodEffects<z.ZodOptional<z.ZodString>, import("../../domain/index.js").RevisionId | undefined, string | undefined>;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
type: "GenerateConfigurationLink";
|
|
45
|
+
name: string;
|
|
46
|
+
frontendUrl: string & import("@salsita-ai/common/utils").Brand<"FrontendUrl">;
|
|
47
|
+
expiration?: number | undefined;
|
|
48
|
+
access: "o" | "r" | "rr";
|
|
49
|
+
configurationId: string & import("@salsita-ai/common/utils").Brand<"ConfigurationId">;
|
|
50
|
+
revisionId?: import("../../domain/index.js").RevisionId | undefined;
|
|
51
|
+
}, {
|
|
52
|
+
type: "GenerateConfigurationLink";
|
|
53
|
+
name: string;
|
|
54
|
+
frontendUrl: string;
|
|
55
|
+
expiration?: number | undefined;
|
|
56
|
+
access: "o" | "r" | "rr";
|
|
57
|
+
configurationId: string;
|
|
58
|
+
revisionId?: string | undefined;
|
|
59
|
+
}>, z.ZodType<SendEmailTask, z.ZodTypeDef, SendEmailTask>, z.ZodType<SendStaticEmailTask, z.ZodTypeDef, SendStaticEmailTask>, z.ZodType<GenerateImagesTask, z.ZodTypeDef, GenerateImagesTask>, z.ZodType<GeneratePdfTask, z.ZodTypeDef, GeneratePdfTask>, z.ZodType<GenerateStaticPdfTask, z.ZodTypeDef, GenerateStaticPdfTask>, z.ZodType<GenerateCsvTask, z.ZodTypeDef, GenerateCsvTask>, z.ZodType<SendHttpRequestTask, z.ZodTypeDef, SendHttpRequestTask>, z.ZodType<WooCommerceAddToCartTask, z.ZodTypeDef, WooCommerceAddToCartTask>, z.ZodType<EditGoogleSpreadsheetTask, z.ZodTypeDef, EditGoogleSpreadsheetTask>, z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"PublishRevision">;
|
|
61
|
+
version: z.ZodEffects<z.ZodNumber, import("../../domain/index.js").PublishedDataRevisionVersion, number>;
|
|
62
|
+
revisionId: z.ZodEffects<z.ZodString, import("../../domain/index.js").RevisionId, string>;
|
|
63
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
type: "PublishRevision";
|
|
66
|
+
version: number & import("@salsita-ai/common/utils").Brand<"PublishedDataRevisionVersion">;
|
|
67
|
+
revisionId: string & import("@salsita-ai/common/utils").Brand<"RevisionId">;
|
|
68
|
+
data: Record<string, unknown>;
|
|
69
|
+
}, {
|
|
70
|
+
type: "PublishRevision";
|
|
71
|
+
version: number;
|
|
72
|
+
revisionId: string;
|
|
73
|
+
data: Record<string, unknown>;
|
|
74
|
+
}>, z.ZodObject<{
|
|
75
|
+
type: z.ZodLiteral<"PublishRevisionChunks">;
|
|
76
|
+
revisionId: z.ZodEffects<z.ZodString, import("../../domain/index.js").RevisionId, string>;
|
|
77
|
+
chunks: z.ZodArray<z.ZodObject<{
|
|
78
|
+
key: z.ZodEffects<z.ZodString, import("../../domain/index.js").ChunkKey, string>;
|
|
79
|
+
scope: z.ZodEffects<z.ZodString, import("../../domain/index.js").ChunkScope, string>;
|
|
80
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
key: string & import("@salsita-ai/common/utils").Brand<"ChunkKey">;
|
|
83
|
+
scope: string & import("@salsita-ai/common/utils").Brand<"ChunkScope">;
|
|
84
|
+
data: Record<string, unknown>;
|
|
85
|
+
}, {
|
|
86
|
+
key: string;
|
|
87
|
+
scope: string;
|
|
88
|
+
data: Record<string, unknown>;
|
|
89
|
+
}>, "many">;
|
|
90
|
+
publishedDataHash: z.ZodString;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
type: "PublishRevisionChunks";
|
|
93
|
+
revisionId: string & import("@salsita-ai/common/utils").Brand<"RevisionId">;
|
|
94
|
+
chunks: {
|
|
95
|
+
key: string & import("@salsita-ai/common/utils").Brand<"ChunkKey">;
|
|
96
|
+
scope: string & import("@salsita-ai/common/utils").Brand<"ChunkScope">;
|
|
97
|
+
data: Record<string, unknown>;
|
|
98
|
+
}[];
|
|
99
|
+
publishedDataHash: string;
|
|
100
|
+
}, {
|
|
101
|
+
type: "PublishRevisionChunks";
|
|
102
|
+
revisionId: string;
|
|
103
|
+
chunks: {
|
|
104
|
+
key: string;
|
|
105
|
+
scope: string;
|
|
106
|
+
data: Record<string, unknown>;
|
|
107
|
+
}[];
|
|
108
|
+
publishedDataHash: string;
|
|
109
|
+
}>, z.ZodObject<{
|
|
110
|
+
type: z.ZodLiteral<"PublishRevisionChunksStaged">;
|
|
111
|
+
revisionId: z.ZodEffects<z.ZodString, import("../../domain/index.js").RevisionId, string>;
|
|
112
|
+
publishedDataHash: z.ZodString;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
type: "PublishRevisionChunksStaged";
|
|
115
|
+
revisionId: string & import("@salsita-ai/common/utils").Brand<"RevisionId">;
|
|
116
|
+
publishedDataHash: string;
|
|
117
|
+
}, {
|
|
118
|
+
type: "PublishRevisionChunksStaged";
|
|
119
|
+
revisionId: string;
|
|
120
|
+
publishedDataHash: string;
|
|
121
|
+
}>, z.ZodType<CallLambdaBackTask<Record<string, unknown>, string>, z.ZodTypeDef, CallLambdaBackTask<Record<string, unknown>, string>>]>, "many">;
|
|
122
|
+
resources: z.ZodArray<z.ZodType<FinalizeTaskResource<string>, z.ZodTypeDef, FinalizeTaskResource<string>>, "many">;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
dataVersion: 1;
|
|
125
|
+
tasks: (CallLambdaBackTask<Record<string, unknown>, string> | EditGoogleSpreadsheetTask | GenerateCsvTask | GenerateImagesTask | GeneratePdfTask | GenerateStaticPdfTask | SendEmailTask | SendHttpRequestTask | SendStaticEmailTask | WooCommerceAddToCartTask | {
|
|
126
|
+
type: "GenerateConfigurationLink";
|
|
127
|
+
name: string;
|
|
128
|
+
frontendUrl: string & import("@salsita-ai/common/utils").Brand<"FrontendUrl">;
|
|
129
|
+
expiration?: number | undefined;
|
|
130
|
+
access: "o" | "r" | "rr";
|
|
131
|
+
configurationId: string & import("@salsita-ai/common/utils").Brand<"ConfigurationId">;
|
|
132
|
+
revisionId?: import("../../domain/index.js").RevisionId | undefined;
|
|
133
|
+
} | {
|
|
134
|
+
type: "PublishRevision";
|
|
135
|
+
version: number & import("@salsita-ai/common/utils").Brand<"PublishedDataRevisionVersion">;
|
|
136
|
+
revisionId: string & import("@salsita-ai/common/utils").Brand<"RevisionId">;
|
|
137
|
+
data: Record<string, unknown>;
|
|
138
|
+
} | {
|
|
139
|
+
type: "PublishRevisionChunks";
|
|
140
|
+
revisionId: string & import("@salsita-ai/common/utils").Brand<"RevisionId">;
|
|
141
|
+
chunks: {
|
|
142
|
+
key: string & import("@salsita-ai/common/utils").Brand<"ChunkKey">;
|
|
143
|
+
scope: string & import("@salsita-ai/common/utils").Brand<"ChunkScope">;
|
|
144
|
+
data: Record<string, unknown>;
|
|
145
|
+
}[];
|
|
146
|
+
publishedDataHash: string;
|
|
147
|
+
} | {
|
|
148
|
+
type: "PublishRevisionChunksStaged";
|
|
149
|
+
revisionId: string & import("@salsita-ai/common/utils").Brand<"RevisionId">;
|
|
150
|
+
publishedDataHash: string;
|
|
151
|
+
})[];
|
|
152
|
+
resources: FinalizeTaskResource<string>[];
|
|
153
|
+
}, {
|
|
154
|
+
dataVersion: 1;
|
|
155
|
+
tasks: (CallLambdaBackTask<Record<string, unknown>, string> | EditGoogleSpreadsheetTask | GenerateCsvTask | GenerateImagesTask | GeneratePdfTask | GenerateStaticPdfTask | SendEmailTask | SendHttpRequestTask | SendStaticEmailTask | WooCommerceAddToCartTask | {
|
|
156
|
+
type: "GenerateConfigurationLink";
|
|
157
|
+
name: string;
|
|
158
|
+
frontendUrl: string;
|
|
159
|
+
expiration?: number | undefined;
|
|
160
|
+
access: "o" | "r" | "rr";
|
|
161
|
+
configurationId: string;
|
|
162
|
+
revisionId?: string | undefined;
|
|
163
|
+
} | {
|
|
164
|
+
type: "PublishRevision";
|
|
165
|
+
version: number;
|
|
166
|
+
revisionId: string;
|
|
167
|
+
data: Record<string, unknown>;
|
|
168
|
+
} | {
|
|
169
|
+
type: "PublishRevisionChunks";
|
|
170
|
+
revisionId: string;
|
|
171
|
+
chunks: {
|
|
172
|
+
key: string;
|
|
173
|
+
scope: string;
|
|
174
|
+
data: Record<string, unknown>;
|
|
175
|
+
}[];
|
|
176
|
+
publishedDataHash: string;
|
|
177
|
+
} | {
|
|
178
|
+
type: "PublishRevisionChunksStaged";
|
|
179
|
+
revisionId: string;
|
|
180
|
+
publishedDataHash: string;
|
|
181
|
+
})[];
|
|
182
|
+
resources: FinalizeTaskResource<string>[];
|
|
183
|
+
}>;
|
|
184
|
+
export declare const validateTaskConfiguration: (task: WebhookFinalizeTaskConfiguration) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{match as e}from"ts-pattern";import{z as t}from"zod";import{TaskType as a}from"../core/index.js";import{FinalizeTaskResource as i,TaskResourceType as r}from"../core/task-resource.js";import{CallLambdaBackTask as s,validateCallLambdaBackTask as o}from"./call-lambda-back-task.js";import{EditGoogleSpreadsheetTask as n}from"./edit-google-spreadsheet-task.js";import{GenerateConfigurationLinkTask as m}from"./generate-configuration-link-task.js";import{GenerateCsvTask as d}from"./generate-csv-task.js";import{GenerateImagesTask as k}from"./generate-images-task.js";import{GeneratePdfTask as f,GenerateStaticPdfTask as l,validateGeneratePdfTask as h,validateGenerateStaticPdfTask as p}from"./generate-pdf-task.js";import{PublishRevisionChunksStagedTask as u}from"./publish-revision-chunks-staged-task.js";import{PublishRevisionChunksTask as c}from"./publish-revision-chunks-task.js";import{PublishRevisionTask as g}from"./publish-revision-task.js";import{SendEmailTask as v,SendStaticEmailTask as y,validateSendEmailTask as b,validateSendStaticEmailTask as C}from"./send-email-task.js";import{SendHttpRequestTask as j}from"./send-http-task.js";import{WooCommerceAddToCartTask as w}from"./woocommerce-add-to-cart-task.js";export const WebhookFinalizeTaskConfiguration=t.object({dataVersion:t.literal(1),tasks:t.array(t.union([m,v,y,k,f,l,d,j,w,n,g,c,u,s])),resources:t.array(i)});export const validateTaskConfiguration=t=>{let i=t.resources.map(e=>e.name);if(new Set(i).size!==i.length){let e=i.filter((e,t)=>i.indexOf(e)!==t);throw Error(`The provided FinalizeTask configuration is invalid! Duplicate resource names: [${[...new Set(e)].join(", ")}].`)}t.resources.forEach(i=>{"exists"in i||"clientGenerated"in i||e(i.type).with(r.Image,()=>{if(!t.tasks.some(e=>e.type===a.GenerateImages&&e.images.some(e=>e.name===i.name)))throw Error(`The provided FinalizeTask configuration is invalid! Resource ${i.name} is not generated by any task. Create a GenerateImages task that generates the image.`)}).with(r.Csv,()=>{if(!t.tasks.some(e=>e.type===a.GenerateCsv&&e.name===i.name))throw Error(`The provided FinalizeTask configuration is invalid! Resource ${i.name} is not generated by any task. Create a GenerateCsv task that generates the CSV.`)}).with(r.Pdf,()=>{if(!t.tasks.some(e=>(e.type===a.GeneratePdf||e.type===a.GenerateStaticPdf)&&e.name===i.name))throw Error(`The provided FinalizeTask configuration is invalid! Resource ${i.name} is not generated by any task. Create a GeneratePdf or GenerateStaticPdf task that generates the PDF.`)}).with(r.ConfigurationLink,()=>{if(!t.tasks.some(e=>e.type===a.GenerateConfigurationLink&&e.name===i.name))throw Error(`The provided FinalizeTask configuration is invalid! Resource ${i.name} is not generated by any task. Create a GenerateConfigurationLink task that generates the configuration link.`)}).exhaustive()});let s=t.tasks.filter(e=>e.type===a.PublishRevision||e.type===a.PublishRevisionChunks||e.type===a.PublishRevisionChunksStaged).length;if(s>1)throw Error(`The provided FinalizeTask configuration is invalid! Only one publish task (PublishRevision, PublishRevisionChunks, or PublishRevisionChunksStaged) is allowed, found ${s}.`);t.tasks.forEach(e=>{e.type===a.GeneratePdf?h(e,t.resources):e.type===a.GenerateStaticPdf?p(e,t.resources):e.type===a.SendEmail?b(e,t.resources):e.type===a.SendStaticEmail?C(e,t.resources):e.type===a.CallLambdaBack&&o(e,t.resources)})};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { AccessLevel } from '../../api/index.js';
|
|
3
|
+
import { ConfigurationId, FrontendUrl, RevisionId } from '../../domain/index.js';
|
|
4
|
+
import { TaskType } from '../core/index.js';
|
|
5
|
+
export interface GenerateConfigurationLinkTask {
|
|
6
|
+
type: typeof TaskType.GenerateConfigurationLink;
|
|
7
|
+
/**
|
|
8
|
+
* The name of the resource to be generated
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* The URL where the frontend is hosted
|
|
13
|
+
*/
|
|
14
|
+
frontendUrl: FrontendUrl;
|
|
15
|
+
/**
|
|
16
|
+
* Expiration time of the generated link in hours, if not provided the link will not expire. Relevant only for revision links as owner links are always permanent.
|
|
17
|
+
*/
|
|
18
|
+
expiration?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The access level of the generated link
|
|
21
|
+
*/
|
|
22
|
+
access: AccessLevel;
|
|
23
|
+
/**
|
|
24
|
+
* The ID of the configuration to generate the link for
|
|
25
|
+
*/
|
|
26
|
+
configurationId: ConfigurationId;
|
|
27
|
+
/**
|
|
28
|
+
* The ID of the revision to generate the link for in the case of a revision link
|
|
29
|
+
*/
|
|
30
|
+
revisionId?: RevisionId;
|
|
31
|
+
}
|
|
32
|
+
export declare const GenerateConfigurationLinkTask: z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"GenerateConfigurationLink">;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
frontendUrl: z.ZodEffects<z.ZodString, FrontendUrl, string>;
|
|
36
|
+
expiration: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
access: z.ZodUnion<[z.ZodLiteral<"o">, z.ZodLiteral<"rr">, z.ZodLiteral<"r">]>;
|
|
38
|
+
configurationId: z.ZodEffects<z.ZodString, ConfigurationId, string>;
|
|
39
|
+
revisionId: z.ZodEffects<z.ZodOptional<z.ZodString>, RevisionId | undefined, string | undefined>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
type: "GenerateConfigurationLink";
|
|
42
|
+
name: string;
|
|
43
|
+
frontendUrl: string & import("@salsita-ai/common/utils").Brand<"FrontendUrl">;
|
|
44
|
+
expiration?: number | undefined;
|
|
45
|
+
access: "o" | "r" | "rr";
|
|
46
|
+
configurationId: string & import("@salsita-ai/common/utils").Brand<"ConfigurationId">;
|
|
47
|
+
revisionId?: RevisionId | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
type: "GenerateConfigurationLink";
|
|
50
|
+
name: string;
|
|
51
|
+
frontendUrl: string;
|
|
52
|
+
expiration?: number | undefined;
|
|
53
|
+
access: "o" | "r" | "rr";
|
|
54
|
+
configurationId: string;
|
|
55
|
+
revisionId?: string | undefined;
|
|
56
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as r}from"zod";import{usingOptionalType as o,usingType as i}from"@salsita-ai/common/utils";import{ConfigurationId as n,FrontendUrl as t,RevisionId as a}from"../../domain/index.js";import{TaskType as e}from"../core/index.js";export const GenerateConfigurationLinkTask=r.object({type:r.literal(e.GenerateConfigurationLink),name:r.string(),frontendUrl:r.string().transform(i(t)),expiration:r.number().optional(),access:r.union([r.literal("o"),r.literal("rr"),r.literal("r")]),configurationId:r.string().transform(i(n)),revisionId:r.string().optional().transform(o(a))});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TaskType } from '../core/index.js';
|
|
3
|
+
export interface GenerateCsvTask {
|
|
4
|
+
readonly type: typeof TaskType.GenerateCsv;
|
|
5
|
+
/**
|
|
6
|
+
* The name of the csv file
|
|
7
|
+
*/
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/**
|
|
10
|
+
* The columns of the csv file
|
|
11
|
+
*/
|
|
12
|
+
readonly columns: readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* The data to be written to the csv file
|
|
15
|
+
*/
|
|
16
|
+
readonly data: unknown[];
|
|
17
|
+
/**
|
|
18
|
+
* Prepend the byte order mark (BOM) to the output stream.
|
|
19
|
+
*/
|
|
20
|
+
readonly bom?: boolean | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Set the field delimiter, one character only, defaults to a comma.
|
|
23
|
+
*/
|
|
24
|
+
readonly delimiter?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Display the column names on the first line if the columns option is provided or discovered.
|
|
27
|
+
*/
|
|
28
|
+
readonly header?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare const GenerateCsvTask: z.ZodType<GenerateCsvTask>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as o}from"zod";import{TaskType as e}from"../core/index.js";export const GenerateCsvTask=o.object({type:o.literal(e.GenerateCsv),name:o.string(),columns:o.array(o.string()),data:o.array(o.unknown()),bom:o.boolean().optional(),delimiter:o.string().optional(),header:o.boolean().optional()});
|