@zapier/zapier-sdk 0.45.2 → 0.46.1
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 +12 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +24 -7
- package/dist/api/schemas.d.ts +5 -5
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/auth.d.ts +27 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +130 -92
- package/dist/cache.d.ts +50 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +47 -0
- package/dist/index.cjs +3108 -3695
- package/dist/index.d.mts +6735 -2188
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +3105 -3696
- package/dist/plugins/api/index.d.ts +22 -10
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +4 -4
- package/dist/plugins/apps/index.d.ts +108 -7
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +3 -4
- package/dist/plugins/capabilities/index.d.ts +9 -6
- package/dist/plugins/capabilities/index.d.ts.map +1 -1
- package/dist/plugins/capabilities/index.js +3 -2
- package/dist/plugins/connections/index.d.ts +15 -9
- package/dist/plugins/connections/index.d.ts.map +1 -1
- package/dist/plugins/connections/index.js +3 -2
- package/dist/plugins/createClientCredentials/index.d.ts +26 -14
- package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/createClientCredentials/index.js +16 -39
- package/dist/plugins/createClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.d.ts +20 -14
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +18 -37
- package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.d.ts +597 -41
- package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.js +9 -8
- package/dist/plugins/eventEmission/index.d.ts +9 -6
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +3 -2
- package/dist/plugins/fetch/index.d.ts +40 -17
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +6 -4
- package/dist/plugins/findFirstConnection/index.d.ts +109 -14
- package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
- package/dist/plugins/findFirstConnection/index.js +14 -26
- package/dist/plugins/findFirstConnection/schemas.d.ts +0 -2
- package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.d.ts +109 -14
- package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.js +14 -26
- package/dist/plugins/findUniqueConnection/schemas.d.ts +0 -2
- package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/index.d.ts +68 -15
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +21 -31
- package/dist/plugins/getAction/schemas.d.ts +4 -6
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts +140 -14
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +16 -38
- package/dist/plugins/getApp/schemas.d.ts +0 -2
- package/dist/plugins/getApp/schemas.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.d.ts +50 -16
- package/dist/plugins/getConnection/index.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.js +22 -29
- package/dist/plugins/getConnection/schemas.d.ts +0 -2
- package/dist/plugins/getConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts +59 -13
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.js +21 -32
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +4 -6
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.d.ts +25 -18
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +13 -26
- package/dist/plugins/getProfile/schemas.d.ts +0 -8
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/schemas.js +0 -1
- package/dist/plugins/listActions/index.d.ts +73 -23
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +25 -53
- package/dist/plugins/listActions/schemas.d.ts +4 -15
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/index.d.ts +121 -13
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +22 -31
- package/dist/plugins/listApps/schemas.d.ts +0 -2
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.d.ts +29 -16
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +17 -37
- package/dist/plugins/listClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/listClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.d.ts +95 -17
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +25 -49
- package/dist/plugins/listConnections/schemas.d.ts +0 -2
- package/dist/plugins/listConnections/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts +77 -22
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +27 -50
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -6
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.d.ts +154 -22
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +28 -41
- package/dist/plugins/listInputFields/schemas.d.ts +4 -6
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/index.d.ts +40 -36
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +3 -2
- package/dist/plugins/registry/index.d.ts +11 -9
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +3 -2
- package/dist/plugins/request/index.d.ts +61 -15
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +14 -22
- package/dist/plugins/request/schemas.d.ts +0 -2
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/index.d.ts +137 -23
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +65 -78
- package/dist/plugins/runAction/schemas.d.ts +4 -14
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTable/index.d.ts +43 -11
- package/dist/plugins/tables/createTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTable/index.js +16 -44
- package/dist/plugins/tables/createTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.d.ts +54 -11
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.js +17 -41
- package/dist/plugins/tables/createTableFields/schemas.d.ts +21 -23
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.d.ts +47 -11
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.js +17 -43
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.d.ts +36 -13
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +18 -40
- package/dist/plugins/tables/deleteTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.d.ts +36 -11
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.js +17 -39
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +36 -11
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.js +18 -41
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.d.ts +43 -12
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.js +18 -43
- package/dist/plugins/tables/getTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.d.ts +43 -11
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.js +18 -42
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +0 -2
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.d.ts +46 -11
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.js +17 -41
- package/dist/plugins/tables/listTableFields/schemas.d.ts +12 -14
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.d.ts +66 -18
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.js +27 -50
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +6 -8
- package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.d.ts +53 -20
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +24 -51
- package/dist/plugins/tables/listTables/schemas.d.ts +0 -2
- package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/shared.d.ts +10 -0
- package/dist/plugins/tables/shared.d.ts.map +1 -0
- package/dist/plugins/tables/shared.js +9 -0
- package/dist/plugins/tables/updateTableRecords/index.d.ts +49 -11
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/updateTableRecords/index.js +20 -43
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/utils.d.ts.map +1 -1
- package/dist/plugins/tables/utils.js +1 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +21 -1
- package/dist/resolvers/actionKey.d.ts +1 -2
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +1 -2
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/schemas/Action.d.ts +1 -1
- package/dist/sdk.d.ts +2942 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/credentials.d.ts +2 -1
- package/dist/types/credentials.d.ts.map +1 -1
- package/dist/types/credentials.js +2 -1
- package/dist/types/errors.d.ts +13 -10
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +15 -12
- package/dist/types/functions.d.ts +18 -2
- package/dist/types/functions.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/properties.d.ts +1 -1
- package/dist/types/registry.d.ts +1 -1
- package/dist/types/registry.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +2 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +1 -0
- package/dist/utils/function-utils.d.ts +11 -12
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/plugin-utils.d.ts +168 -0
- package/dist/utils/plugin-utils.d.ts.map +1 -0
- package/dist/utils/plugin-utils.js +132 -0
- package/package.json +2 -4
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,aAAa,EACb,MAAM,EACN,cAAc,EACd,UAAU,EACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AA8ChE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAE3D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB;;;;EAE5D;AAED,wBAAgB,SAAS;;cACW,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;;cAA1B,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;;kBAqBxB,MAAM;oBAAK,cAAc;cAcjD,SAAS,SAAS,cAAc;;kBAnCV,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;;;kBAA1B,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;;EAC7D;AA4ED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,gBAAqB;;cAlFzC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAHj2N;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -25,7 +25,8 @@ export declare const ClientCredentialsObjectSchema: z.ZodObject<{
|
|
|
25
25
|
export type ClientCredentialsObject = z.infer<typeof ClientCredentialsObjectSchema>;
|
|
26
26
|
/**
|
|
27
27
|
* PKCE credentials for interactive OAuth flow.
|
|
28
|
-
* Only works when @zapier/zapier-sdk-cli
|
|
28
|
+
* Only works when @zapier/zapier-sdk-cli is installed (the SDK dynamically
|
|
29
|
+
* imports its `./login` entry point).
|
|
29
30
|
*/
|
|
30
31
|
export declare const PkceCredentialsObjectSchema: z.ZodObject<{
|
|
31
32
|
type: z.ZodOptional<z.ZodEnum<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/types/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;iBAoBxC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/types/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;iBAoBxC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;;;;;iBAgBtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;mBAGlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;qBAGpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAKnC,CAAC;AACJ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAG5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,mBAAmB,GAC/B,WAAW,IAAI,uBAAuB,CAOxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,mBAAmB,GAC/B,WAAW,IAAI,qBAAqB,CAOtC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,mBAAmB,GAC/B,WAAW,IAAI,iBAAiB,CAMlC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,WAAW,GACvB,WAAW,IAAI,mBAAmB,CAEpC"}
|
|
@@ -36,7 +36,8 @@ export const ClientCredentialsObjectSchema = z.object({
|
|
|
36
36
|
});
|
|
37
37
|
/**
|
|
38
38
|
* PKCE credentials for interactive OAuth flow.
|
|
39
|
-
* Only works when @zapier/zapier-sdk-cli
|
|
39
|
+
* Only works when @zapier/zapier-sdk-cli is installed (the SDK dynamically
|
|
40
|
+
* imports its `./login` entry point).
|
|
40
41
|
*/
|
|
41
42
|
export const PkceCredentialsObjectSchema = z.object({
|
|
42
43
|
type: z.enum(["pkce"]).optional().meta({ internal: true }),
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -78,9 +78,20 @@ export declare class ZapierAuthenticationError extends ZapierError {
|
|
|
78
78
|
constructor(message: string, options?: ErrorOptions);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
* Error thrown when a
|
|
81
|
+
* Error thrown when a resource is not found (404)
|
|
82
|
+
*/
|
|
83
|
+
export declare class ZapierNotFoundError extends ZapierError {
|
|
84
|
+
readonly name: string;
|
|
85
|
+
readonly code: string;
|
|
86
|
+
constructor(message: string, options?: ErrorOptions);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Error thrown when a requested resource is not found and the caller
|
|
90
|
+
* provided a `resource` hint on the request, populating `resourceType`
|
|
91
|
+
* and (optionally) `resourceId`. Subclass of `ZapierNotFoundError` so
|
|
92
|
+
* `instanceof ZapierNotFoundError` checks continue to work.
|
|
82
93
|
*/
|
|
83
|
-
export declare class ZapierResourceNotFoundError extends
|
|
94
|
+
export declare class ZapierResourceNotFoundError extends ZapierNotFoundError {
|
|
84
95
|
readonly name = "ZapierResourceNotFoundError";
|
|
85
96
|
readonly code: "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
|
|
86
97
|
resourceType?: string;
|
|
@@ -140,14 +151,6 @@ export declare class ZapierActionError extends ZapierError {
|
|
|
140
151
|
});
|
|
141
152
|
get actionErrors(): ApiError[] | undefined;
|
|
142
153
|
}
|
|
143
|
-
/**
|
|
144
|
-
* Error thrown when a resource is not found (404)
|
|
145
|
-
*/
|
|
146
|
-
export declare class ZapierNotFoundError extends ZapierError {
|
|
147
|
-
readonly name = "ZapierNotFoundError";
|
|
148
|
-
readonly code: "ZAPIER_NOT_FOUND_ERROR";
|
|
149
|
-
constructor(message: string, options?: ErrorOptions);
|
|
150
|
-
}
|
|
151
154
|
/**
|
|
152
155
|
* Rate limit information extracted from response headers
|
|
153
156
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC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C,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;gBAGtB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,YAAY,GAAG;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,cAAc,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KACb;CAQT;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,IAAI,EAAG,oBAAoB,CAAU;gBAElC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAGxD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAsF7D"}
|
package/dist/types/errors.js
CHANGED
|
@@ -66,9 +66,22 @@ export class ZapierAuthenticationError extends ZapierError {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Error thrown when a
|
|
69
|
+
* Error thrown when a resource is not found (404)
|
|
70
|
+
*/
|
|
71
|
+
export class ZapierNotFoundError extends ZapierError {
|
|
72
|
+
constructor(message, options = {}) {
|
|
73
|
+
super(message, options);
|
|
74
|
+
this.name = "ZapierNotFoundError";
|
|
75
|
+
this.code = "ZAPIER_NOT_FOUND_ERROR";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Error thrown when a requested resource is not found and the caller
|
|
80
|
+
* provided a `resource` hint on the request, populating `resourceType`
|
|
81
|
+
* and (optionally) `resourceId`. Subclass of `ZapierNotFoundError` so
|
|
82
|
+
* `instanceof ZapierNotFoundError` checks continue to work.
|
|
70
83
|
*/
|
|
71
|
-
export class ZapierResourceNotFoundError extends
|
|
84
|
+
export class ZapierResourceNotFoundError extends ZapierNotFoundError {
|
|
72
85
|
constructor(message, options = {}) {
|
|
73
86
|
super(message, options);
|
|
74
87
|
this.name = "ZapierResourceNotFoundError";
|
|
@@ -128,16 +141,6 @@ export class ZapierActionError extends ZapierError {
|
|
|
128
141
|
return this.errors;
|
|
129
142
|
}
|
|
130
143
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Error thrown when a resource is not found (404)
|
|
133
|
-
*/
|
|
134
|
-
export class ZapierNotFoundError extends ZapierError {
|
|
135
|
-
constructor(message, options = {}) {
|
|
136
|
-
super(message, options);
|
|
137
|
-
this.name = "ZapierNotFoundError";
|
|
138
|
-
this.code = "ZAPIER_NOT_FOUND_ERROR";
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
144
|
/**
|
|
142
145
|
* Error thrown when rate limited (429) after all retries are exhausted
|
|
143
146
|
*/
|
|
@@ -16,11 +16,27 @@ export interface FunctionOptions {
|
|
|
16
16
|
/** Custom fetch implementation */
|
|
17
17
|
fetch?: typeof globalThis.fetch;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Single page of a paginated SDK list result. Returned from the page-level
|
|
21
|
+
* promise and yielded from the page-level async iterable.
|
|
22
|
+
*/
|
|
19
23
|
export interface SdkPage<T = unknown> {
|
|
20
24
|
data: T[];
|
|
21
25
|
nextCursor?: string;
|
|
22
26
|
}
|
|
23
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Return type of every paginated SDK method. The same value is both:
|
|
29
|
+
*
|
|
30
|
+
* - a Promise that resolves to the first page (`SdkPage<TItem>`), and
|
|
31
|
+
* - an AsyncIterable that yields each page in turn,
|
|
32
|
+
*
|
|
33
|
+
* with an `.items()` method that returns an AsyncIterable over individual
|
|
34
|
+
* items across all pages. Named so paginated plugin signatures serialize
|
|
35
|
+
* as `PaginatedSdkResult<AppItem>` in `.d.ts` rather than expanding the
|
|
36
|
+
* full triple-intersection at every callsite.
|
|
37
|
+
*/
|
|
38
|
+
export interface PaginatedSdkResult<TItem> extends Promise<SdkPage<TItem>>, AsyncIterable<SdkPage<TItem>> {
|
|
24
39
|
items(): AsyncIterable<TItem>;
|
|
25
|
-
}
|
|
40
|
+
}
|
|
41
|
+
export type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => PaginatedSdkResult<TItem>;
|
|
26
42
|
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/types/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C;;GAEG;AAGH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,2CAA2C;IAC3C,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAClC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/types/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C;;GAEG;AAGH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,2CAA2C;IAC3C,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAClC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB,CAAC,KAAK,CACvC,SAAQ,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAC7B,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,KAAK,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;CAC/B;AAGD,MAAM,MAAM,oBAAoB,CAAC,QAAQ,EAAE,KAAK,IAAI,CAClD,OAAO,EAAE,QAAQ,KACd,kBAAkB,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface PluginMeta {
|
|
|
26
26
|
*/
|
|
27
27
|
description?: string;
|
|
28
28
|
categories?: string[];
|
|
29
|
-
type?: "list" | "item" | "create" | "delete";
|
|
29
|
+
type?: "list" | "item" | "create" | "update" | "delete" | "function";
|
|
30
30
|
itemType?: string;
|
|
31
31
|
returnType?: string;
|
|
32
32
|
inputSchema?: z.ZodSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC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CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,MAAM,CACrB,IAAI,GAAG,EAAE,EACT,SAAS,SAAS,cAAc,GAAG,cAAc;IAEjD,CACE,GAAG,EAAE,IAAI,GAAG;QACV,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;SAClC,CAAC;KACH,GACA,SAAS,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CACvB,CAAC,GAAG;IAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;KAAE,CAAA;CAAE,IACnD,CAAC,GAAG;IACN,SAAS,CAAC,SAAS,SAAS,cAAc,EACxC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,GAC3B,aAAa,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAChC,WAAW,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc,CAAC;CAC7D,CAAC"}
|
|
@@ -6,11 +6,11 @@ export declare const AppPropertySchema: z.ZodString & {
|
|
|
6
6
|
_def: z.core.$ZodStringDef & import("..").PositionalMetadata;
|
|
7
7
|
};
|
|
8
8
|
export declare const ActionTypePropertySchema: z.ZodEnum<{
|
|
9
|
-
search: "search";
|
|
10
9
|
filter: "filter";
|
|
11
10
|
read: "read";
|
|
12
11
|
read_bulk: "read_bulk";
|
|
13
12
|
run: "run";
|
|
13
|
+
search: "search";
|
|
14
14
|
search_and_write: "search_and_write";
|
|
15
15
|
search_or_write: "search_or_write";
|
|
16
16
|
write: "write";
|
package/dist/types/registry.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface FunctionRegistryEntry {
|
|
|
8
8
|
* directly rather than relying solely on inputSchema.describe().
|
|
9
9
|
*/
|
|
10
10
|
description?: string;
|
|
11
|
-
type?: "list" | "item" | "create" | "delete";
|
|
11
|
+
type?: "list" | "item" | "create" | "update" | "delete" | "function";
|
|
12
12
|
itemType?: string;
|
|
13
13
|
returnType?: string;
|
|
14
14
|
inputSchema?: z.ZodSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/types/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/types/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;IAC/D,YAAY,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0FAA0F;IAC1F,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,kFAAkF;IAClF,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,qBAAqB,EAAE,CAAC;IACnC,UAAU,EAAE;QACV,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,EAAE,CAAC;CACL"}
|
package/dist/types/sdk.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
import type { EventCallback } from "./events";
|
|
6
6
|
import type { EventEmissionConfig } from "../plugins/eventEmission";
|
|
7
7
|
import type { Manifest } from "../plugins/manifest";
|
|
8
|
+
import type { ZapierCache } from "../cache";
|
|
8
9
|
export declare const BaseSdkOptionsSchema: z.ZodObject<{
|
|
9
10
|
credentials: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
10
11
|
type: z.ZodOptional<z.ZodEnum<{
|
|
@@ -76,6 +77,7 @@ export declare const BaseSdkOptionsSchema: z.ZodObject<{
|
|
|
76
77
|
name: string;
|
|
77
78
|
version: string;
|
|
78
79
|
}>>;
|
|
80
|
+
cache: z.ZodOptional<z.ZodCustom<ZapierCache, ZapierCache>>;
|
|
79
81
|
canIncludeSharedConnections: z.ZodOptional<z.ZodBoolean>;
|
|
80
82
|
canIncludeSharedTables: z.ZodOptional<z.ZodBoolean>;
|
|
81
83
|
canDeleteTables: z.ZodOptional<z.ZodBoolean>;
|
package/dist/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgFb,MAAM;iBAAW,MAAM;;cAAvB,MAAM;iBAAW,MAAM;;;;;;;iBAiBzC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAG7E,MAAM,WAAW,kBACf,SAAQ,0BAA0B,EAChC,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,uBAAuB;CAAG"}
|
package/dist/types/sdk.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Generic utility functions for creating paginated SDK functions
|
|
3
3
|
*/
|
|
4
4
|
import type { z } from "zod";
|
|
5
|
+
import type { PaginatedSdkResult } from "../types/functions";
|
|
5
6
|
/**
|
|
6
7
|
* Callbacks for telemetry events during function execution
|
|
7
8
|
*/
|
|
@@ -37,24 +38,22 @@ export declare function createFunction<TOptions, TResult, TSchemaOptions extends
|
|
|
37
38
|
* @param coreFn - Function that returns T directly or throws errors
|
|
38
39
|
* @returns A function that normalizes errors and wraps results in {data}
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
41
|
+
/**
|
|
42
|
+
* Extract the item type from a page handler's return shape. The handler
|
|
43
|
+
* may return a flat `{ data: TItem[] }` (or single `data: TItem`), a bare
|
|
44
|
+
* array, or a JSON:API envelope; in all cases the wrapper normalizes to
|
|
45
|
+
* `SdkPage<TItem>` and this resolves the right `TItem`.
|
|
46
|
+
*/
|
|
47
47
|
type ItemType<TResult> = TResult extends {
|
|
48
48
|
data: infer TData;
|
|
49
49
|
} ? TData extends readonly (infer TItem)[] ? TItem : TData : TResult extends readonly (infer TItem)[] ? TItem : TResult;
|
|
50
|
-
export declare function createPaginatedFunction<
|
|
50
|
+
export declare function createPaginatedFunction<TUserOptions, TResult>(coreFn: (options: TUserOptions & {
|
|
51
|
+
cursor?: string;
|
|
51
52
|
pageSize?: number;
|
|
52
|
-
}) => Promise<TResult>, schema?: z.ZodSchema<
|
|
53
|
+
}) => Promise<TResult>, schema?: z.ZodSchema<TUserOptions>, telemetry?: TelemetryCallbacks, explicitFunctionName?: string, defaultPageSize?: number): (options?: TUserOptions & {
|
|
53
54
|
cursor?: string;
|
|
54
55
|
pageSize?: number;
|
|
55
56
|
maxItems?: number;
|
|
56
|
-
}) =>
|
|
57
|
-
items(): AsyncIterable<ItemType<TResult>>;
|
|
58
|
-
};
|
|
57
|
+
}) => PaginatedSdkResult<ItemType<TResult>>;
|
|
59
58
|
export {};
|
|
60
59
|
//# sourceMappingURL=function-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-utils.d.ts","sourceRoot":"","sources":["../../src/utils/function-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"function-utils.d.ts","sourceRoot":"","sources":["../../src/utils/function-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAQ7D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE;QACtB,UAAU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CAAC,EAClC,SAAS,CAAC,EAAE,kBAAkB,EAC9B,oBAAoB,CAAC,EAAE,MAAM,EAC7B,eAAe,CAAC,EAAE,MAAM,GACvB,CACD,OAAO,CAAC,EAAE,YAAY,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KACE,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAiHzC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ------------------------------
|
|
3
|
+
* Plugin authoring helpers
|
|
4
|
+
* ------------------------------
|
|
5
|
+
*
|
|
6
|
+
* - `definePlugin`: identity wrapper that constrains a plugin's return to
|
|
7
|
+
* `PluginProvides` while preserving the narrow inferred shape, so callers
|
|
8
|
+
* can derive their `*PluginProvides` type via `ReturnType<typeof plugin>`
|
|
9
|
+
* instead of declaring it by hand.
|
|
10
|
+
* - `createPluginMethod` / `createPaginatedPluginMethod`: per-method
|
|
11
|
+
* primitives that sit inside a `definePlugin` callback and build the
|
|
12
|
+
*
|
|
13
|
+
* { [name]: wrappedFn, context: { meta: { [name]: meta } } }
|
|
14
|
+
*
|
|
15
|
+
* fragment a plugin returns for a single method, wiring up
|
|
16
|
+
* `createFunction` / `createPaginatedFunction`, the telemetry callback,
|
|
17
|
+
* and the doubled `name` (function key + meta key) in one place.
|
|
18
|
+
*
|
|
19
|
+
* Two method helpers (rather than one with a `paginated: true` discriminant)
|
|
20
|
+
* because the handler signature changes shape across pagination, and
|
|
21
|
+
* discriminated unions on optional booleans produce noisy TS errors.
|
|
22
|
+
*/
|
|
23
|
+
import type { z } from "zod";
|
|
24
|
+
import type { PaginatedSdkResult } from "../types/functions";
|
|
25
|
+
import type { PluginMeta, PluginProvides } from "../types/plugin";
|
|
26
|
+
/**
|
|
27
|
+
* Identity helper that preserves the narrow inferred return type of a plugin.
|
|
28
|
+
*
|
|
29
|
+
* Wrapping a plugin function with `definePlugin(...)` lets callers derive the
|
|
30
|
+
* plugin's contribution via `ReturnType<typeof plugin>` instead of declaring a
|
|
31
|
+
* matching `*PluginProvides` interface by hand. The constraint
|
|
32
|
+
* `TProvides extends PluginProvides` enforces the structural floor (must
|
|
33
|
+
* return a valid plugin output); beyond that the inferred shape flows through.
|
|
34
|
+
*/
|
|
35
|
+
export declare function definePlugin<TSdk, TProvides extends PluginProvides>(fn: (sdk: TSdk & {
|
|
36
|
+
context: {
|
|
37
|
+
meta: Record<string, PluginMeta>;
|
|
38
|
+
};
|
|
39
|
+
}) => TProvides): (sdk: TSdk & {
|
|
40
|
+
context: {
|
|
41
|
+
meta: Record<string, PluginMeta>;
|
|
42
|
+
};
|
|
43
|
+
}) => TProvides;
|
|
44
|
+
/**
|
|
45
|
+
* Method-level meta fields. Mirrors `PluginMeta` minus `inputSchema`, which is
|
|
46
|
+
* passed at the top level alongside the handler and merged into the meta by
|
|
47
|
+
* the helpers themselves.
|
|
48
|
+
*/
|
|
49
|
+
type MethodMeta = Omit<PluginMeta, "inputSchema">;
|
|
50
|
+
interface PluginMethodConfig<TSdk, TInput, TResult, TName extends string> extends MethodMeta {
|
|
51
|
+
name: TName;
|
|
52
|
+
/**
|
|
53
|
+
* Schema for runtime input validation; drives the handler's `options`
|
|
54
|
+
* type. For plugins that accept deprecated parameter aliases this is a
|
|
55
|
+
* `z.union([CanonicalSchema, DeprecatedSchema])` — the registry
|
|
56
|
+
* unwraps unions and exposes only the first variant (canonical) to
|
|
57
|
+
* docs, CLI help, and MCP tool definitions.
|
|
58
|
+
*/
|
|
59
|
+
inputSchema?: z.ZodSchema<TInput>;
|
|
60
|
+
handler: (args: {
|
|
61
|
+
sdk: TSdk;
|
|
62
|
+
options: TInput;
|
|
63
|
+
}) => Promise<TResult>;
|
|
64
|
+
}
|
|
65
|
+
type PluginMethodReturn<TName extends string, TInput, TResult> = {
|
|
66
|
+
[K in TName]: (options?: TInput) => Promise<TResult>;
|
|
67
|
+
} & {
|
|
68
|
+
context: {
|
|
69
|
+
meta: {
|
|
70
|
+
[K in TName]: PluginMeta;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Build the method fragment for a non-paginated SDK method. Used inside a
|
|
76
|
+
* `definePlugin(...)` callback:
|
|
77
|
+
*
|
|
78
|
+
* export const getProfilePlugin = definePlugin(
|
|
79
|
+
* (sdk: ApiPluginProvides & EventEmissionProvides) =>
|
|
80
|
+
* createPluginMethod(sdk, {
|
|
81
|
+
* name: "getProfile",
|
|
82
|
+
* categories: ["account"],
|
|
83
|
+
* inputSchema: GetProfileSchema,
|
|
84
|
+
* handler: async ({ sdk }) => { ... },
|
|
85
|
+
* }),
|
|
86
|
+
* );
|
|
87
|
+
*/
|
|
88
|
+
export declare function createPluginMethod<const TName extends string, TSdk extends {
|
|
89
|
+
context: unknown;
|
|
90
|
+
}, TInput, TResult>(sdk: TSdk, config: PluginMethodConfig<TSdk, TInput, TResult, TName>): PluginMethodReturn<TName, TInput, TResult>;
|
|
91
|
+
interface PaginatedPluginMethodConfig<TSdk, TInput, TResponse extends {
|
|
92
|
+
data: unknown[];
|
|
93
|
+
}, TName extends string> extends MethodMeta {
|
|
94
|
+
name: TName;
|
|
95
|
+
/** Same semantics as `createPluginMethod`'s `inputSchema`. */
|
|
96
|
+
inputSchema?: z.ZodSchema<TInput>;
|
|
97
|
+
/**
|
|
98
|
+
* Optional default page size when the caller doesn't pass one. Mirrors
|
|
99
|
+
* `createPaginatedFunction`'s `defaultPageSize` arg.
|
|
100
|
+
*/
|
|
101
|
+
defaultPageSize?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Page handler. Returns whatever shape the upstream API gives back, as
|
|
104
|
+
* long as it has a `data: TItem[]` field. JSON:API envelopes
|
|
105
|
+
* (`{ data, links, meta }`) work directly: pair them with
|
|
106
|
+
* `extractCursor` below to pull the next-page cursor out of the response.
|
|
107
|
+
*/
|
|
108
|
+
handler: (args: {
|
|
109
|
+
sdk: TSdk;
|
|
110
|
+
options: TInput & {
|
|
111
|
+
cursor?: string;
|
|
112
|
+
pageSize?: number;
|
|
113
|
+
};
|
|
114
|
+
}) => Promise<TResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Pull the next-page cursor out of the handler's response. Most JSON:API
|
|
117
|
+
* endpoints will use `(response) => extractCursor(response.links)` from
|
|
118
|
+
* `function-utils`. Provide a custom extractor for non-standard shapes
|
|
119
|
+
* (e.g. `(response) => response.meta?.pagination?.end_cursor`).
|
|
120
|
+
*
|
|
121
|
+
* If omitted, the runtime falls back to its built-in detection
|
|
122
|
+
* (`response.nextCursor` or `response.links?.next` URL parsing) — i.e.
|
|
123
|
+
* the same auto-detection that worked before this helper existed. New
|
|
124
|
+
* plugins should set `extractCursor` explicitly so the pagination shape
|
|
125
|
+
* is visible at the call site.
|
|
126
|
+
*/
|
|
127
|
+
extractCursor?: (response: TResponse) => string | undefined;
|
|
128
|
+
}
|
|
129
|
+
type ItemOf<TResponse extends {
|
|
130
|
+
data: unknown[];
|
|
131
|
+
}> = TResponse extends {
|
|
132
|
+
data: readonly (infer TItem)[];
|
|
133
|
+
} ? TItem : never;
|
|
134
|
+
type PaginatedPluginMethodReturn<TName extends string, TInput, TItem> = {
|
|
135
|
+
[K in TName]: (options?: TInput & {
|
|
136
|
+
cursor?: string;
|
|
137
|
+
pageSize?: number;
|
|
138
|
+
maxItems?: number;
|
|
139
|
+
}) => PaginatedSdkResult<TItem>;
|
|
140
|
+
} & {
|
|
141
|
+
context: {
|
|
142
|
+
meta: {
|
|
143
|
+
[K in TName]: PluginMeta;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Paginated variant of `createPluginMethod`. The handler receives
|
|
149
|
+
* `{ cursor?, pageSize? }` in `options` and returns whatever shape the
|
|
150
|
+
* upstream API gives back, as long as it has a `data: TItem[]` field.
|
|
151
|
+
* Pair JSON:API responses with `extractCursor` to make the cursor
|
|
152
|
+
* extraction visible at the call site:
|
|
153
|
+
*
|
|
154
|
+
* createPaginatedPluginMethod(sdk, {
|
|
155
|
+
* name: "listApps",
|
|
156
|
+
* inputSchema: ListAppsSchema,
|
|
157
|
+
* handler: ({ sdk, options }) =>
|
|
158
|
+
* sdk.context.api.get<ListAppsResponse>("/api/v0/apps", {...}),
|
|
159
|
+
* extractCursor: (response) => extractCursor(response.links),
|
|
160
|
+
* });
|
|
161
|
+
*/
|
|
162
|
+
export declare function createPaginatedPluginMethod<const TName extends string, TSdk extends {
|
|
163
|
+
context: unknown;
|
|
164
|
+
}, TInput, TResponse extends {
|
|
165
|
+
data: unknown[];
|
|
166
|
+
}>(sdk: TSdk, config: PaginatedPluginMethodConfig<TSdk, TInput, TResponse, TName>): PaginatedPluginMethodReturn<TName, TInput, ItemOf<TResponse>>;
|
|
167
|
+
export {};
|
|
168
|
+
//# sourceMappingURL=plugin-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-utils.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMlE;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,SAAS,cAAc,EACjE,EAAE,EAAE,CACF,GAAG,EAAE,IAAI,GAAG;IAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;KAAE,CAAA;CAAE,KAC1D,SAAS,GACb,CACD,GAAG,EAAE,IAAI,GAAG;IAAE,OAAO,EAAE;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,CAAC,KAAK,SAAS,MAAM,EAC1B,IAAI,SAAS;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,EACjC,MAAM,EACN,SAAS,SAAS;IAAE,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,EAErC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,GAClE,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAiD/D"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ------------------------------
|
|
3
|
+
* Plugin authoring helpers
|
|
4
|
+
* ------------------------------
|
|
5
|
+
*
|
|
6
|
+
* - `definePlugin`: identity wrapper that constrains a plugin's return to
|
|
7
|
+
* `PluginProvides` while preserving the narrow inferred shape, so callers
|
|
8
|
+
* can derive their `*PluginProvides` type via `ReturnType<typeof plugin>`
|
|
9
|
+
* instead of declaring it by hand.
|
|
10
|
+
* - `createPluginMethod` / `createPaginatedPluginMethod`: per-method
|
|
11
|
+
* primitives that sit inside a `definePlugin` callback and build the
|
|
12
|
+
*
|
|
13
|
+
* { [name]: wrappedFn, context: { meta: { [name]: meta } } }
|
|
14
|
+
*
|
|
15
|
+
* fragment a plugin returns for a single method, wiring up
|
|
16
|
+
* `createFunction` / `createPaginatedFunction`, the telemetry callback,
|
|
17
|
+
* and the doubled `name` (function key + meta key) in one place.
|
|
18
|
+
*
|
|
19
|
+
* Two method helpers (rather than one with a `paginated: true` discriminant)
|
|
20
|
+
* because the handler signature changes shape across pagination, and
|
|
21
|
+
* discriminated unions on optional booleans produce noisy TS errors.
|
|
22
|
+
*/
|
|
23
|
+
import { createFunction, createPaginatedFunction } from "./function-utils";
|
|
24
|
+
import { createTelemetryCallback } from "./telemetry-utils";
|
|
25
|
+
/**
|
|
26
|
+
* Identity helper that preserves the narrow inferred return type of a plugin.
|
|
27
|
+
*
|
|
28
|
+
* Wrapping a plugin function with `definePlugin(...)` lets callers derive the
|
|
29
|
+
* plugin's contribution via `ReturnType<typeof plugin>` instead of declaring a
|
|
30
|
+
* matching `*PluginProvides` interface by hand. The constraint
|
|
31
|
+
* `TProvides extends PluginProvides` enforces the structural floor (must
|
|
32
|
+
* return a valid plugin output); beyond that the inferred shape flows through.
|
|
33
|
+
*/
|
|
34
|
+
export function definePlugin(fn) {
|
|
35
|
+
return fn;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build a telemetry callback only when the SDK actually has eventEmission
|
|
39
|
+
* wired up. Plugin tests sometimes assemble a minimal SDK without the
|
|
40
|
+
* eventEmission plugin; in that case telemetry is silently skipped, matching
|
|
41
|
+
* the legacy `createFunction` behavior of accepting an undefined telemetry
|
|
42
|
+
* arg.
|
|
43
|
+
*/
|
|
44
|
+
function maybeTelemetry(sdk, name) {
|
|
45
|
+
const ctx = sdk.context;
|
|
46
|
+
if (!ctx.eventEmission)
|
|
47
|
+
return undefined;
|
|
48
|
+
return createTelemetryCallback(ctx.eventEmission.emitMethodCalled, name);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build the method fragment for a non-paginated SDK method. Used inside a
|
|
52
|
+
* `definePlugin(...)` callback:
|
|
53
|
+
*
|
|
54
|
+
* export const getProfilePlugin = definePlugin(
|
|
55
|
+
* (sdk: ApiPluginProvides & EventEmissionProvides) =>
|
|
56
|
+
* createPluginMethod(sdk, {
|
|
57
|
+
* name: "getProfile",
|
|
58
|
+
* categories: ["account"],
|
|
59
|
+
* inputSchema: GetProfileSchema,
|
|
60
|
+
* handler: async ({ sdk }) => { ... },
|
|
61
|
+
* }),
|
|
62
|
+
* );
|
|
63
|
+
*/
|
|
64
|
+
export function createPluginMethod(sdk, config) {
|
|
65
|
+
const { name, inputSchema, handler, ...metaFields } = config;
|
|
66
|
+
// Preserve the method name on the inner function so telemetry and any
|
|
67
|
+
// `function.name`-based diagnostics see the right value.
|
|
68
|
+
const namedHandlers = {
|
|
69
|
+
[name]: async function (options) {
|
|
70
|
+
return handler({ sdk, options });
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const wrappedFn = createFunction(namedHandlers[name], inputSchema, maybeTelemetry(sdk, name));
|
|
74
|
+
return {
|
|
75
|
+
[name]: wrappedFn,
|
|
76
|
+
context: {
|
|
77
|
+
meta: {
|
|
78
|
+
[name]: {
|
|
79
|
+
...metaFields,
|
|
80
|
+
...(inputSchema ? { inputSchema } : {}),
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Paginated variant of `createPluginMethod`. The handler receives
|
|
88
|
+
* `{ cursor?, pageSize? }` in `options` and returns whatever shape the
|
|
89
|
+
* upstream API gives back, as long as it has a `data: TItem[]` field.
|
|
90
|
+
* Pair JSON:API responses with `extractCursor` to make the cursor
|
|
91
|
+
* extraction visible at the call site:
|
|
92
|
+
*
|
|
93
|
+
* createPaginatedPluginMethod(sdk, {
|
|
94
|
+
* name: "listApps",
|
|
95
|
+
* inputSchema: ListAppsSchema,
|
|
96
|
+
* handler: ({ sdk, options }) =>
|
|
97
|
+
* sdk.context.api.get<ListAppsResponse>("/api/v0/apps", {...}),
|
|
98
|
+
* extractCursor: (response) => extractCursor(response.links),
|
|
99
|
+
* });
|
|
100
|
+
*/
|
|
101
|
+
export function createPaginatedPluginMethod(sdk, config) {
|
|
102
|
+
const { name, inputSchema, handler, extractCursor: extractCursorFn, defaultPageSize, ...metaFields } = config;
|
|
103
|
+
const namedPageHandlers = {
|
|
104
|
+
[name]: async function (options) {
|
|
105
|
+
const response = await handler({ sdk, options });
|
|
106
|
+
if (extractCursorFn) {
|
|
107
|
+
const extracted = extractCursorFn(response);
|
|
108
|
+
// Pass through the original response when the extractor doesn't
|
|
109
|
+
// produce a cursor — that way the runtime in `createPageFunction`
|
|
110
|
+
// can still auto-detect `nextCursor` or JSON:API `links.next` if
|
|
111
|
+
// they're present (e.g. from test mocks that don't go through the
|
|
112
|
+
// real API envelope).
|
|
113
|
+
if (extracted !== undefined) {
|
|
114
|
+
return { data: response.data, nextCursor: extracted };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return response;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
const wrappedFn = createPaginatedFunction(namedPageHandlers[name], inputSchema, maybeTelemetry(sdk, name), name, defaultPageSize);
|
|
121
|
+
return {
|
|
122
|
+
[name]: wrappedFn,
|
|
123
|
+
context: {
|
|
124
|
+
meta: {
|
|
125
|
+
[name]: {
|
|
126
|
+
...metaFields,
|
|
127
|
+
...(inputSchema ? { inputSchema } : {}),
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|