@zapier/zapier-sdk 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +10 -33
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +1 -2
- package/dist/api/polling.d.ts +36 -6
- package/dist/api/polling.d.ts.map +1 -1
- package/dist/api/polling.js +132 -28
- package/dist/api/polling.test.d.ts +2 -0
- package/dist/api/polling.test.d.ts.map +1 -0
- package/dist/api/polling.test.js +318 -0
- package/dist/api/types.d.ts +1 -2
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +489 -252
- package/dist/index.d.mts +182 -187
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.mjs +486 -251
- package/dist/plugins/apps/index.d.ts +4 -0
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts +2 -7
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +9 -9
- package/dist/plugins/getApp/index.test.js +1 -1
- package/dist/plugins/getAuthentication/index.test.js +1 -1
- package/dist/plugins/listActions/index.d.ts +2 -4
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +1 -1
- package/dist/plugins/listActions/index.test.js +4 -4
- package/dist/plugins/listApps/index.d.ts +4 -7
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +33 -17
- package/dist/plugins/listApps/index.test.js +22 -2
- package/dist/plugins/listAuthentications/index.d.ts +2 -4
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +4 -0
- package/dist/plugins/listAuthentications/index.test.js +39 -13
- package/dist/plugins/listAuthentications/schemas.d.ts +3 -0
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/schemas.js +4 -0
- package/dist/plugins/manifest/index.d.ts +25 -9
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +239 -67
- package/dist/plugins/manifest/index.test.js +426 -171
- package/dist/plugins/manifest/schemas.d.ts +5 -1
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +1 -0
- package/dist/sdk.d.ts +5 -11
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1 -4
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +6 -3
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/domain-utils.d.ts +16 -0
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +46 -27
- package/dist/utils/domain-utils.test.js +157 -3
- package/dist/utils/file-utils.d.ts +4 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +74 -0
- package/dist/utils/file-utils.test.d.ts +2 -0
- package/dist/utils/file-utils.test.d.ts.map +1 -0
- package/dist/utils/file-utils.test.js +51 -0
- package/package.json +1 -1
- package/src/api/client.ts +5 -4
- package/src/api/polling.test.ts +405 -0
- package/src/api/polling.ts +224 -44
- package/src/api/types.ts +1 -2
- package/src/index.ts +1 -1
- package/src/plugins/apps/index.ts +9 -2
- package/src/plugins/getApp/index.test.ts +1 -1
- package/src/plugins/getApp/index.ts +12 -14
- package/src/plugins/getAuthentication/index.test.ts +1 -1
- package/src/plugins/listActions/index.test.ts +8 -7
- package/src/plugins/listActions/index.ts +3 -3
- package/src/plugins/listApps/index.test.ts +23 -2
- package/src/plugins/listApps/index.ts +46 -25
- package/src/plugins/listAuthentications/index.test.ts +52 -15
- package/src/plugins/listAuthentications/index.ts +7 -2
- package/src/plugins/listAuthentications/schemas.ts +4 -0
- package/src/plugins/manifest/index.test.ts +503 -197
- package/src/plugins/manifest/index.ts +338 -82
- package/src/plugins/manifest/schemas.ts +9 -2
- package/src/sdk.ts +1 -5
- package/src/types/plugin.ts +3 -0
- package/src/types/sdk.ts +26 -21
- package/src/utils/domain-utils.test.ts +196 -2
- package/src/utils/domain-utils.ts +68 -35
- package/src/utils/file-utils.test.ts +73 -0
- package/src/utils/file-utils.ts +94 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/plugins/lockVersion/index.d.ts +0 -24
- package/dist/plugins/lockVersion/index.d.ts.map +0 -1
- package/dist/plugins/lockVersion/index.js +0 -72
- package/dist/plugins/lockVersion/index.test.d.ts +0 -2
- package/dist/plugins/lockVersion/index.test.d.ts.map +0 -1
- package/dist/plugins/lockVersion/index.test.js +0 -129
- package/dist/plugins/lockVersion/schemas.d.ts +0 -10
- package/dist/plugins/lockVersion/schemas.d.ts.map +0 -1
- package/dist/plugins/lockVersion/schemas.js +0 -6
- package/src/plugins/lockVersion/index.test.ts +0 -176
- package/src/plugins/lockVersion/index.ts +0 -112
- package/src/plugins/lockVersion/schemas.ts +0 -9
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { ResolvedAppLocator } from "../../utils/domain-utils";
|
|
2
3
|
import type { AppItem } from "../../types/domain";
|
|
4
|
+
export declare const DEFAULT_CONFIG_PATH: ".zapierrc";
|
|
3
5
|
export type ManifestEntry = {
|
|
4
6
|
implementationName: string;
|
|
5
7
|
version?: string;
|
|
6
8
|
};
|
|
7
|
-
export type GetManifestEntry = (appKey: string) => ManifestEntry | null;
|
|
8
9
|
export type GetVersionedImplementationId = (appKey: string) => Promise<string | null>;
|
|
9
10
|
export type GetImplementation = (appKey: string) => Promise<AppItem | null>;
|
|
10
11
|
export type Manifest = {
|
|
11
12
|
apps: Record<string, ManifestEntry>;
|
|
12
13
|
};
|
|
14
|
+
export type ResolveAppKeys = ({ appKeys, }: {
|
|
15
|
+
appKeys: string[];
|
|
16
|
+
}) => Promise<ResolvedAppLocator[]>;
|
|
13
17
|
/**
|
|
14
18
|
* Manifest schema for version locking
|
|
15
19
|
* Maps app keys to their locked version information
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/manifest/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/manifest/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,mBAAmB,EAAG,WAAoB,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,CACzC,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAE5E,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,EAC5B,OAAO,GACR,EAAE;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,KAAK,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;EAcoC,CAAC;AAEhE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;EAYtC,CAAC"}
|
package/dist/sdk.d.ts
CHANGED
|
@@ -6,20 +6,20 @@ export interface ZapierSdkOptions extends BaseSdkOptions {
|
|
|
6
6
|
export declare function createSdk<TCurrentSdk = {}, TCurrentContext = {
|
|
7
7
|
meta: Record<string, PluginMeta>;
|
|
8
8
|
}>(options?: ZapierSdkOptions, initialSdk?: TCurrentSdk, initialContext?: TCurrentContext): Sdk<TCurrentSdk, TCurrentContext>;
|
|
9
|
-
export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<import("./types/plugin").ExtractSdkProperties<import(".").ApiPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").
|
|
9
|
+
export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<import("./types/plugin").ExtractSdkProperties<import(".").ApiPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ManifestPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListAppsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetAppPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListActionsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetActionPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListInputFieldsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import("./plugins/listInputFieldChoices").ListInputFieldChoicesPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").RunActionPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListAuthenticationsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FindFirstAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FindUniqueAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").RequestPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FetchPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").AppsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetProfilePluginProvides>, {
|
|
10
10
|
meta: Record<string, PluginMeta>;
|
|
11
11
|
} & {
|
|
12
12
|
api: import("./api").ApiClient;
|
|
13
|
+
} & {
|
|
14
|
+
getVersionedImplementationId: import("./plugins/manifest/schemas").GetVersionedImplementationId;
|
|
15
|
+
resolveAppKeys: import("./plugins/manifest/schemas").ResolveAppKeys;
|
|
16
|
+
updateManifestEntry: (appKey: string, entry: import("./plugins/manifest/schemas").ManifestEntry, configPath?: string) => Promise<[string, import("./plugins/manifest/schemas").ManifestEntry]>;
|
|
13
17
|
} & {
|
|
14
18
|
meta: {
|
|
15
19
|
listApps: {
|
|
16
20
|
inputSchema: typeof import("./plugins/listApps/schemas").ListAppsSchema;
|
|
17
21
|
};
|
|
18
22
|
};
|
|
19
|
-
} & {
|
|
20
|
-
getVersionedImplementationId: import("./plugins/manifest/schemas").GetVersionedImplementationId;
|
|
21
|
-
getManifestEntry: import("./plugins/manifest/schemas").GetManifestEntry;
|
|
22
|
-
getImplementation: import("./plugins/manifest/schemas").GetImplementation;
|
|
23
23
|
} & {
|
|
24
24
|
meta: {
|
|
25
25
|
getApp: {
|
|
@@ -56,12 +56,6 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
|
|
|
56
56
|
inputSchema: typeof import("./plugins/runAction/schemas").RunActionSchema;
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
-
} & {
|
|
60
|
-
meta: {
|
|
61
|
-
lockVersion: {
|
|
62
|
-
inputSchema: typeof import("./plugins/lockVersion/schemas").LockVersionSchema;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
59
|
} & {
|
|
66
60
|
meta: {
|
|
67
61
|
listAuthentications: {
|
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;AAMlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,EAIH,UAAU,EACX,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,EAIH,UAAU,EACX,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,wBAAgB,SAAS,CACvB,WAAW,GAAG,EAAE,EAChB,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,EAEtD,OAAO,GAAE,gBAAqB,EAC9B,UAAU,GAAE,WAA+B,EAC3C,cAAc,GAAE,eAAiD,GAChE,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAqEnC;AAED,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,gBAAqB;UA5EjD,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;;;;;+GAbpD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6HF;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAMzE"}
|
package/dist/sdk.js
CHANGED
|
@@ -17,7 +17,6 @@ import { listInputFieldsPlugin } from "./plugins/listInputFields";
|
|
|
17
17
|
import { listInputFieldChoicesPlugin } from "./plugins/listInputFieldChoices";
|
|
18
18
|
import { requestPlugin } from "./plugins/request";
|
|
19
19
|
import { manifestPlugin } from "./plugins/manifest";
|
|
20
|
-
import { lockVersionPlugin } from "./plugins/lockVersion";
|
|
21
20
|
// Create SDK that supports flat plugins - returns an SDK, not a builder
|
|
22
21
|
export function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} }) {
|
|
23
22
|
return {
|
|
@@ -78,9 +77,9 @@ export function createZapierSdkWithoutRegistry(options = {}) {
|
|
|
78
77
|
// Provides the API client in context
|
|
79
78
|
.addPlugin(apiPlugin)
|
|
80
79
|
// Manifest plugin (provides version locking context)
|
|
80
|
+
.addPlugin(manifestPlugin)
|
|
81
81
|
// Apps/actions/fields
|
|
82
82
|
.addPlugin(listAppsPlugin)
|
|
83
|
-
.addPlugin(manifestPlugin)
|
|
84
83
|
.addPlugin(getAppPlugin)
|
|
85
84
|
.addPlugin(listActionsPlugin)
|
|
86
85
|
.addPlugin(getActionPlugin)
|
|
@@ -88,8 +87,6 @@ export function createZapierSdkWithoutRegistry(options = {}) {
|
|
|
88
87
|
.addPlugin(listInputFieldChoicesPlugin)
|
|
89
88
|
// Run action
|
|
90
89
|
.addPlugin(runActionPlugin)
|
|
91
|
-
// Version locking
|
|
92
|
-
.addPlugin(lockVersionPlugin)
|
|
93
90
|
// Authentications
|
|
94
91
|
.addPlugin(listAuthenticationsPlugin)
|
|
95
92
|
.addPlugin(getAuthenticationPlugin)
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type ExtractContextProperties<T extends PluginProvides> = T["context"];
|
|
|
25
25
|
export type GetSdkType<TPluginProvides extends PluginProvides> = ExtractSdkProperties<TPluginProvides> & {
|
|
26
26
|
getContext(): NonNullable<ExtractContextProperties<TPluginProvides>>;
|
|
27
27
|
};
|
|
28
|
+
export type GetContextType<TPluginProvides extends PluginProvides> = NonNullable<ExtractContextProperties<TPluginProvides>>;
|
|
28
29
|
export type PluginOptions<TSdk = {}, TContext = {}> = {
|
|
29
30
|
sdk: TSdk;
|
|
30
31
|
context: TContext & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,WAAW,kBAAkB,CAAC,IAAI,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE;IAC1D,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,QAAQ,CAAC;CACnB;AAGD,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAGD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CACpE,CAAC,EACD,SAAS,CACV,CAAC;AAGF,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC;AAG9E,MAAM,MAAM,UAAU,CAAC,eAAe,SAAS,cAAc,IAC3D,oBAAoB,CAAC,eAAe,CAAC,GAAG;IACtC,UAAU,IAAI,WAAW,CAAC,wBAAwB,CAAC,eAAe,CAAC,CAAC,CAAC;CACtE,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GA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AAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,IACpD,WAAW,GAAG;IAChB,SAAS,CAAC,gBAAgB,EAAE,SAAS,SAAS,cAAc,EAC1D,MAAM,EAAE,MAAM,CACZ,WAAW,GAAG;QAAE,UAAU,IAAI,eAAe,CAAA;KAAE,EAC/C,gBAAgB,EAChB,SAAS,CACV,EACD,OAAO,CAAC,EAAE,GAAG,GACZ,eAAe,SAAS,gBAAgB,GACvC,GAAG,CACD,WAAW,GAAG,oBAAoB,CAAC,SAAS,CAAC,EAC7C,eAAe,GAAG,WAAW,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,CACnE,GACD,YAAY,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;IACpD,UAAU,IAAI,eAAe,CAAC;CAC/B,CAAC"}
|
package/dist/types/sdk.d.ts
CHANGED
|
@@ -24,11 +24,11 @@ import type { GetAuthenticationSdkFunction } from "../plugins/getAuthentication/
|
|
|
24
24
|
import type { FindFirstAuthenticationSdkFunction } from "../plugins/findFirstAuthentication/schemas";
|
|
25
25
|
import type { FindUniqueAuthenticationSdkFunction } from "../plugins/findUniqueAuthentication/schemas";
|
|
26
26
|
import type { RelayRequestSdkFunction } from "../plugins/request/schemas";
|
|
27
|
-
import type { LockVersionPluginProvides } from "../plugins/lockVersion";
|
|
28
27
|
import type { z } from "zod";
|
|
29
28
|
import type { RegistryPluginProvides } from "../plugins/registry";
|
|
30
29
|
import type { GetProfilePluginProvides } from "../plugins/getProfile";
|
|
31
|
-
import type { AppsPluginProvides } from "../plugins/apps";
|
|
30
|
+
import type { AppsPluginProvides, ZapierSdkApps } from "../plugins/apps";
|
|
31
|
+
import type { ActionProxy } from "../plugins/apps/types";
|
|
32
32
|
import type { FetchPluginProvides } from "../plugins/fetch";
|
|
33
33
|
import type { ListAppsPluginProvides } from "../plugins/listApps";
|
|
34
34
|
import type { GetAppPluginProvides } from "../plugins/getApp";
|
|
@@ -40,6 +40,7 @@ import type { GetAuthenticationPluginProvides } from "../plugins/getAuthenticati
|
|
|
40
40
|
import type { FindFirstAuthenticationPluginProvides } from "../plugins/findFirstAuthentication";
|
|
41
41
|
import type { FindUniqueAuthenticationPluginProvides } from "../plugins/findUniqueAuthentication";
|
|
42
42
|
import type { ListInputFieldsPluginProvides } from "../plugins/listInputFields";
|
|
43
|
+
import type { ListInputFieldChoicesPluginProvides } from "../plugins/listInputFieldChoices";
|
|
43
44
|
import type { RequestPluginProvides } from "../plugins/request";
|
|
44
45
|
import type { GetSdkType } from "./plugin";
|
|
45
46
|
import type { ManifestPluginProvides } from "../plugins/manifest";
|
|
@@ -50,5 +51,7 @@ export interface FunctionRegistryEntry {
|
|
|
50
51
|
}
|
|
51
52
|
export interface ZapierSdkFunctions extends ListInputFieldsSdkFunction, GetAuthenticationSdkFunction, FindFirstAuthenticationSdkFunction, FindUniqueAuthenticationSdkFunction, RelayRequestSdkFunction {
|
|
52
53
|
}
|
|
53
|
-
export
|
|
54
|
+
export interface ZapierSdk extends GetSdkType<RegistryPluginProvides & FetchPluginProvides & AppsPluginProvides & ListAppsPluginProvides & ManifestPluginProvides & GetAppPluginProvides & ListActionsPluginProvides & GetActionPluginProvides & RunActionPluginProvides & ListAuthenticationsPluginProvides & GetAuthenticationPluginProvides & FindFirstAuthenticationPluginProvides & FindUniqueAuthenticationPluginProvides & ListInputFieldsPluginProvides & ListInputFieldChoicesPluginProvides & RequestPluginProvides & GetProfilePluginProvides> {
|
|
55
|
+
apps: ActionProxy & ZapierSdkApps;
|
|
56
|
+
}
|
|
54
57
|
//# sourceMappingURL=sdk.d.ts.map
|
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,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC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+B,EAAE,MAAM,8BAA8B,CAAC;AACpF,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAClG,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAMlE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAGD,MAAM,WAAW,kBACf,SAAQ,0BAA0B,EAChC,4BAA4B,EAC5B,kCAAkC,EAClC,mCAAmC,EACnC,uBAAuB;CAE1B;AAUD,MAAM,WAAW,SACf,SAAQ,UAAU,CAChB,sBAAsB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,sBAAsB,GACtB,oBAAoB,GACpB,yBAAyB,GACzB,uBAAuB,GACvB,uBAAuB,GACvB,iCAAiC,GACjC,+BAA+B,GAC/B,qCAAqC,GACrC,sCAAsC,GACtC,6BAA6B,GAC7B,mCAAmC,GACnC,qBAAqB,GACrB,wBAAwB,CAC3B;IAED,IAAI,EAAE,WAAW,GAAG,aAAa,CAAC;CACnC"}
|
|
@@ -75,4 +75,20 @@ export declare function groupAppKeysByType(appKeys: string[]): {
|
|
|
75
75
|
selectedApi: string[];
|
|
76
76
|
slug: string[];
|
|
77
77
|
};
|
|
78
|
+
export declare function isSlug(slug: string): boolean;
|
|
79
|
+
export declare function isSnakeCasedSlug(slug: string): boolean;
|
|
80
|
+
export declare function dashifySnakeCasedSlug(slug: string): string;
|
|
81
|
+
export interface AppLocator {
|
|
82
|
+
lookupAppKey: string;
|
|
83
|
+
slug?: string;
|
|
84
|
+
implementationName?: string;
|
|
85
|
+
version?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ResolvedAppLocator extends AppLocator {
|
|
88
|
+
implementationName: string;
|
|
89
|
+
}
|
|
90
|
+
export declare function isUuid(appKey: string): boolean;
|
|
91
|
+
export declare function toAppLocator(appKey: string): AppLocator;
|
|
92
|
+
export declare function isResolvedAppLocator(appLocator: AppLocator): appLocator is ResolvedAppLocator;
|
|
93
|
+
export declare function toImplementationId(appLocator: ResolvedAppLocator): string;
|
|
78
94
|
//# sourceMappingURL=domain-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-utils.d.ts","sourceRoot":"","sources":["../../src/utils/domain-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,GAAG,EACH,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,OAAO,EACR,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GACnB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAQ9B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAYlD;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,cAAc,EAAE,cAAc,GAC7B,OAAO,CAYT;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CAWT;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAYnE;AAED;;;;;;;;GAQG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
|
157
157
|
const seenSelectedApi = new Set();
|
|
158
158
|
const seenSlugs = new Set();
|
|
159
159
|
for (const key of appKeys) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const dashified = dashifySnakeCasedSlug(keyWithoutVersion);
|
|
170
|
-
const slugWithVersion = version ? `${dashified}@${version}` : dashified;
|
|
171
|
-
if (!seenSlugs.has(slugWithVersion)) {
|
|
172
|
-
seenSlugs.add(slugWithVersion);
|
|
173
|
-
result.slug.push(slugWithVersion); // Preserve full key including version
|
|
160
|
+
const appLocator = toAppLocator(key);
|
|
161
|
+
if (appLocator.slug) {
|
|
162
|
+
// For slugs, we need to reconstruct the versioned slug
|
|
163
|
+
const versionedSlug = appLocator.version
|
|
164
|
+
? `${appLocator.slug}@${appLocator.version}`
|
|
165
|
+
: appLocator.slug;
|
|
166
|
+
if (!seenSlugs.has(versionedSlug)) {
|
|
167
|
+
seenSlugs.add(versionedSlug);
|
|
168
|
+
result.slug.push(versionedSlug);
|
|
174
169
|
}
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
// Check if it's a slug (lowercase and dashes)
|
|
178
|
-
if (keyWithoutVersion.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)) {
|
|
179
|
-
seenSlugs.add(key);
|
|
180
|
-
result.slug.push(key);
|
|
181
|
-
continue;
|
|
182
170
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
seenSelectedApi.
|
|
186
|
-
|
|
171
|
+
else {
|
|
172
|
+
// For implementation names (selectedApi)
|
|
173
|
+
if (!seenSelectedApi.has(key)) {
|
|
174
|
+
seenSelectedApi.add(key);
|
|
175
|
+
result.selectedApi.push(key);
|
|
176
|
+
}
|
|
187
177
|
}
|
|
188
178
|
}
|
|
189
179
|
return result;
|
|
@@ -198,14 +188,17 @@ export function groupAppKeysByType(appKeys) {
|
|
|
198
188
|
slug: [...new Set(grouped.slug.map((key) => key.split("@")[0]))],
|
|
199
189
|
};
|
|
200
190
|
}
|
|
201
|
-
function
|
|
191
|
+
export function isSlug(slug) {
|
|
192
|
+
return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
193
|
+
}
|
|
194
|
+
export function isSnakeCasedSlug(slug) {
|
|
202
195
|
// Allow leading underscore for slugs starting with a number.
|
|
203
196
|
if (slug.match(/^_[0-9]/)) {
|
|
204
197
|
slug = slug.slice(1);
|
|
205
198
|
}
|
|
206
199
|
return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
|
|
207
200
|
}
|
|
208
|
-
function dashifySnakeCasedSlug(slug) {
|
|
201
|
+
export function dashifySnakeCasedSlug(slug) {
|
|
209
202
|
// Only dashify if it's a valid snake_cased slug.
|
|
210
203
|
if (!isSnakeCasedSlug(slug)) {
|
|
211
204
|
return slug;
|
|
@@ -216,3 +209,29 @@ function dashifySnakeCasedSlug(slug) {
|
|
|
216
209
|
}
|
|
217
210
|
return slug.replace(/_/g, "-");
|
|
218
211
|
}
|
|
212
|
+
export function isUuid(appKey) {
|
|
213
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(appKey);
|
|
214
|
+
}
|
|
215
|
+
export function toAppLocator(appKey) {
|
|
216
|
+
const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
|
|
217
|
+
if (isUuid(appKeyWithoutVersion)) {
|
|
218
|
+
throw new Error(`UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`);
|
|
219
|
+
}
|
|
220
|
+
const slug = isSlug(appKeyWithoutVersion)
|
|
221
|
+
? appKeyWithoutVersion
|
|
222
|
+
: isSnakeCasedSlug(appKeyWithoutVersion)
|
|
223
|
+
? dashifySnakeCasedSlug(appKeyWithoutVersion)
|
|
224
|
+
: undefined;
|
|
225
|
+
return {
|
|
226
|
+
lookupAppKey: appKeyWithoutVersion,
|
|
227
|
+
slug,
|
|
228
|
+
implementationName: slug ? undefined : appKeyWithoutVersion,
|
|
229
|
+
version,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
export function isResolvedAppLocator(appLocator) {
|
|
233
|
+
return !!appLocator.implementationName;
|
|
234
|
+
}
|
|
235
|
+
export function toImplementationId(appLocator) {
|
|
236
|
+
return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
|
|
237
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { groupVersionedAppKeysByType, groupAppKeysByType, } from "./domain-utils";
|
|
2
|
+
import { groupVersionedAppKeysByType, groupAppKeysByType, toAppLocator, } from "./domain-utils";
|
|
3
3
|
describe("domain-utils", () => {
|
|
4
4
|
describe("groupVersionedAppKeysByType", () => {
|
|
5
5
|
it("should reject UUID app keys", () => {
|
|
@@ -105,10 +105,12 @@ describe("domain-utils", () => {
|
|
|
105
105
|
"FormatterCLIAPI@1.0.0",
|
|
106
106
|
"slack@2.1.0", // exact duplicate
|
|
107
107
|
"FormatterCLIAPI@1.0.0", // exact duplicate
|
|
108
|
+
"slack@2.1.1",
|
|
109
|
+
"FormatterCLIAPI@1.0.1",
|
|
108
110
|
]);
|
|
109
111
|
expect(result).toEqual({
|
|
110
|
-
selectedApi: ["FormatterCLIAPI@1.0.0"],
|
|
111
|
-
slug: ["slack@2.1.0"],
|
|
112
|
+
selectedApi: ["FormatterCLIAPI@1.0.0", "FormatterCLIAPI@1.0.1"],
|
|
113
|
+
slug: ["slack@2.1.0", "slack@2.1.1"],
|
|
112
114
|
});
|
|
113
115
|
});
|
|
114
116
|
});
|
|
@@ -189,4 +191,156 @@ describe("domain-utils", () => {
|
|
|
189
191
|
});
|
|
190
192
|
});
|
|
191
193
|
});
|
|
194
|
+
describe("toAppLocator", () => {
|
|
195
|
+
it("should reject UUID app keys", () => {
|
|
196
|
+
expect(() => {
|
|
197
|
+
toAppLocator("61e47557-af91-4b0c-a3e0-c28606357664");
|
|
198
|
+
}).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61e47557-af91-4b0c-a3e0-c28606357664");
|
|
199
|
+
});
|
|
200
|
+
it("should reject UUID app keys with versions", () => {
|
|
201
|
+
expect(() => {
|
|
202
|
+
toAppLocator("61e47557-af91-4b0c-a3e0-c28606357664@1.0.0");
|
|
203
|
+
}).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61e47557-af91-4b0c-a3e0-c28606357664@1.0.0");
|
|
204
|
+
});
|
|
205
|
+
it("should reject uppercase UUID app keys", () => {
|
|
206
|
+
expect(() => {
|
|
207
|
+
toAppLocator("61E47557-AF91-4B0C-A3E0-C28606357664");
|
|
208
|
+
}).toThrow("UUID app keys are not supported. Use app slug or implementation ID instead of: 61E47557-AF91-4B0C-A3E0-C28606357664");
|
|
209
|
+
});
|
|
210
|
+
it("should handle simple slug without version", () => {
|
|
211
|
+
const result = toAppLocator("slack");
|
|
212
|
+
expect(result).toEqual({
|
|
213
|
+
lookupAppKey: "slack",
|
|
214
|
+
slug: "slack",
|
|
215
|
+
implementationName: undefined,
|
|
216
|
+
version: undefined,
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
it("should handle slug with version", () => {
|
|
220
|
+
const result = toAppLocator("slack@1.0.0");
|
|
221
|
+
expect(result).toEqual({
|
|
222
|
+
lookupAppKey: "slack",
|
|
223
|
+
slug: "slack",
|
|
224
|
+
implementationName: undefined,
|
|
225
|
+
version: "1.0.0",
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
it("should handle dashified slug", () => {
|
|
229
|
+
const result = toAppLocator("google-sheets");
|
|
230
|
+
expect(result).toEqual({
|
|
231
|
+
lookupAppKey: "google-sheets",
|
|
232
|
+
slug: "google-sheets",
|
|
233
|
+
implementationName: undefined,
|
|
234
|
+
version: undefined,
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
it("should handle dashified slug with version", () => {
|
|
238
|
+
const result = toAppLocator("google-sheets@2.1.3");
|
|
239
|
+
expect(result).toEqual({
|
|
240
|
+
lookupAppKey: "google-sheets",
|
|
241
|
+
slug: "google-sheets",
|
|
242
|
+
implementationName: undefined,
|
|
243
|
+
version: "2.1.3",
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
it("should handle snake_cased slug and convert to dash", () => {
|
|
247
|
+
const result = toAppLocator("google_sheets");
|
|
248
|
+
expect(result).toEqual({
|
|
249
|
+
lookupAppKey: "google_sheets",
|
|
250
|
+
slug: "google-sheets",
|
|
251
|
+
implementationName: undefined,
|
|
252
|
+
version: undefined,
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
it("should handle snake_cased slug with version and convert to dash", () => {
|
|
256
|
+
const result = toAppLocator("google_sheets@2.1.3");
|
|
257
|
+
expect(result).toEqual({
|
|
258
|
+
lookupAppKey: "google_sheets",
|
|
259
|
+
slug: "google-sheets",
|
|
260
|
+
implementationName: undefined,
|
|
261
|
+
version: "2.1.3",
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
it("should handle leading underscore snake_cased slug", () => {
|
|
265
|
+
const result = toAppLocator("_100hires_ats");
|
|
266
|
+
expect(result).toEqual({
|
|
267
|
+
lookupAppKey: "_100hires_ats",
|
|
268
|
+
slug: "100hires-ats",
|
|
269
|
+
implementationName: undefined,
|
|
270
|
+
version: undefined,
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
it("should handle leading underscore snake_cased slug with version", () => {
|
|
274
|
+
const result = toAppLocator("_100hires_ats@3.0.0");
|
|
275
|
+
expect(result).toEqual({
|
|
276
|
+
lookupAppKey: "_100hires_ats",
|
|
277
|
+
slug: "100hires-ats",
|
|
278
|
+
implementationName: undefined,
|
|
279
|
+
version: "3.0.0",
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
it("should handle implementation name without version", () => {
|
|
283
|
+
const result = toAppLocator("SlackCLIAPI");
|
|
284
|
+
expect(result).toEqual({
|
|
285
|
+
lookupAppKey: "SlackCLIAPI",
|
|
286
|
+
slug: undefined,
|
|
287
|
+
implementationName: "SlackCLIAPI",
|
|
288
|
+
version: undefined,
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
it("should handle implementation name with version", () => {
|
|
292
|
+
const result = toAppLocator("SlackCLIAPI@1.29.0");
|
|
293
|
+
expect(result).toEqual({
|
|
294
|
+
lookupAppKey: "SlackCLIAPI",
|
|
295
|
+
slug: undefined,
|
|
296
|
+
implementationName: "SlackCLIAPI",
|
|
297
|
+
version: "1.29.0",
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
it("should handle edge cases with complex version numbers", () => {
|
|
301
|
+
const result = toAppLocator("slack@1.2.3-beta.4+build.5");
|
|
302
|
+
expect(result).toEqual({
|
|
303
|
+
lookupAppKey: "slack",
|
|
304
|
+
slug: "slack",
|
|
305
|
+
implementationName: undefined,
|
|
306
|
+
version: "1.2.3-beta.4+build.5",
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
it("should handle single character app keys", () => {
|
|
310
|
+
const result = toAppLocator("a");
|
|
311
|
+
expect(result).toEqual({
|
|
312
|
+
lookupAppKey: "a",
|
|
313
|
+
slug: "a",
|
|
314
|
+
implementationName: undefined,
|
|
315
|
+
version: undefined,
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
it("should handle app keys with numbers", () => {
|
|
319
|
+
const result = toAppLocator("app123");
|
|
320
|
+
expect(result).toEqual({
|
|
321
|
+
lookupAppKey: "app123",
|
|
322
|
+
slug: "app123",
|
|
323
|
+
implementationName: undefined,
|
|
324
|
+
version: undefined,
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
it("should handle mixed case app keys that aren't implementation names", () => {
|
|
328
|
+
const result = toAppLocator("SlackBot");
|
|
329
|
+
expect(result).toEqual({
|
|
330
|
+
lookupAppKey: "SlackBot",
|
|
331
|
+
slug: undefined,
|
|
332
|
+
implementationName: "SlackBot",
|
|
333
|
+
version: undefined,
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
it("should handle empty version (app key ending with @)", () => {
|
|
337
|
+
const result = toAppLocator("slack@");
|
|
338
|
+
expect(result).toEqual({
|
|
339
|
+
lookupAppKey: "slack",
|
|
340
|
+
slug: "slack",
|
|
341
|
+
implementationName: undefined,
|
|
342
|
+
version: "",
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
});
|
|
192
346
|
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function resolve(path: string, basePath?: string): Promise<string>;
|
|
2
|
+
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
3
|
+
export declare function readFile(filePath: string): Promise<string>;
|
|
4
|
+
//# sourceMappingURL=file-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AA6BA,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAY,GACrB,OAAO,CAAC,MAAM,CAAC,CA8BjB;AAED,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAchE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// In-memory filesystem fallback for browser environments
|
|
2
|
+
const inMemoryFiles = {};
|
|
3
|
+
// Lazy-loaded modules
|
|
4
|
+
let fsPromises = null;
|
|
5
|
+
let pathModule = null;
|
|
6
|
+
async function loadFsPromises() {
|
|
7
|
+
if (fsPromises)
|
|
8
|
+
return fsPromises;
|
|
9
|
+
try {
|
|
10
|
+
fsPromises = await import("fs/promises");
|
|
11
|
+
return fsPromises;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function loadPathModule() {
|
|
18
|
+
if (pathModule)
|
|
19
|
+
return pathModule;
|
|
20
|
+
try {
|
|
21
|
+
pathModule = await import("path");
|
|
22
|
+
return pathModule;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export async function resolve(path, basePath = "/") {
|
|
29
|
+
const pathModule = await loadPathModule();
|
|
30
|
+
if (pathModule) {
|
|
31
|
+
return pathModule.resolve(path);
|
|
32
|
+
}
|
|
33
|
+
// Simple fallback path resolution assuming root "/" location
|
|
34
|
+
if (path.startsWith("/")) {
|
|
35
|
+
return path;
|
|
36
|
+
}
|
|
37
|
+
if (path.startsWith("./")) {
|
|
38
|
+
// Remove ./ prefix and join to base
|
|
39
|
+
const cleanPath = path.slice(2);
|
|
40
|
+
return basePath.endsWith("/")
|
|
41
|
+
? basePath + cleanPath
|
|
42
|
+
: basePath + "/" + cleanPath;
|
|
43
|
+
}
|
|
44
|
+
if (path.startsWith("../")) {
|
|
45
|
+
// Remove ../ prefix since we're already at root
|
|
46
|
+
const cleanPath = path.replace(/^(\.\.\/)+/, "");
|
|
47
|
+
return basePath.endsWith("/")
|
|
48
|
+
? basePath + cleanPath
|
|
49
|
+
: basePath + "/" + cleanPath;
|
|
50
|
+
}
|
|
51
|
+
// No slash prefix, join to base
|
|
52
|
+
return basePath.endsWith("/") ? basePath + path : basePath + "/" + path;
|
|
53
|
+
}
|
|
54
|
+
export async function writeFile(filePath, content) {
|
|
55
|
+
const fs = await loadFsPromises();
|
|
56
|
+
if (fs) {
|
|
57
|
+
await fs.writeFile(filePath, content, "utf8");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Fallback to in-memory filesystem
|
|
61
|
+
inMemoryFiles[filePath] = content;
|
|
62
|
+
}
|
|
63
|
+
export async function readFile(filePath) {
|
|
64
|
+
const fs = await loadFsPromises();
|
|
65
|
+
if (fs) {
|
|
66
|
+
return await fs.readFile(filePath, "utf8");
|
|
67
|
+
}
|
|
68
|
+
// Fallback to in-memory filesystem
|
|
69
|
+
const content = inMemoryFiles[filePath];
|
|
70
|
+
if (content !== undefined) {
|
|
71
|
+
return content;
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`File not found: ${filePath}`);
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { resolve, writeFile, readFile } from "./file-utils";
|
|
3
|
+
// Mock the dynamic imports to simulate missing modules
|
|
4
|
+
vi.mock("fs/promises", () => {
|
|
5
|
+
throw new Error("Module not found");
|
|
6
|
+
});
|
|
7
|
+
vi.mock("path", () => {
|
|
8
|
+
throw new Error("Module not found");
|
|
9
|
+
});
|
|
10
|
+
describe("file-utils", () => {
|
|
11
|
+
describe("resolve", () => {
|
|
12
|
+
it("should handle absolute paths", async () => {
|
|
13
|
+
expect(await resolve("/absolute/path")).toBe("/absolute/path");
|
|
14
|
+
});
|
|
15
|
+
it("should handle relative paths with ./", async () => {
|
|
16
|
+
expect(await resolve("./relative/path")).toBe("/relative/path");
|
|
17
|
+
expect(await resolve("./relative/path", "/base")).toBe("/base/relative/path");
|
|
18
|
+
expect(await resolve("./relative/path", "/base/")).toBe("/base/relative/path");
|
|
19
|
+
});
|
|
20
|
+
it("should handle parent directory paths with ../", async () => {
|
|
21
|
+
expect(await resolve("../parent/path")).toBe("/parent/path");
|
|
22
|
+
expect(await resolve("../../nested/parent/path")).toBe("/nested/parent/path");
|
|
23
|
+
expect(await resolve("../parent/path", "/base")).toBe("/base/parent/path");
|
|
24
|
+
});
|
|
25
|
+
it("should handle paths without prefix", async () => {
|
|
26
|
+
expect(await resolve("simple/path")).toBe("/simple/path");
|
|
27
|
+
expect(await resolve("simple/path", "/base")).toBe("/base/simple/path");
|
|
28
|
+
expect(await resolve("simple/path", "/base/")).toBe("/base/simple/path");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe("writeFile and readFile with in-memory filesystem", () => {
|
|
32
|
+
it("should write and read files using in-memory filesystem when fs is not available", async () => {
|
|
33
|
+
const filePath = "/test/file.txt";
|
|
34
|
+
const content = "Hello, world!";
|
|
35
|
+
await writeFile(filePath, content);
|
|
36
|
+
const readContent = await readFile(filePath);
|
|
37
|
+
expect(readContent).toBe(content);
|
|
38
|
+
});
|
|
39
|
+
it("should throw error when reading non-existent file", async () => {
|
|
40
|
+
await expect(readFile("/non/existent/file.txt")).rejects.toThrow("File not found: /non/existent/file.txt");
|
|
41
|
+
});
|
|
42
|
+
it("should handle multiple files in in-memory filesystem", async () => {
|
|
43
|
+
await writeFile("/file1.txt", "content1");
|
|
44
|
+
await writeFile("/file2.txt", "content2");
|
|
45
|
+
await writeFile("/dir/file3.txt", "content3");
|
|
46
|
+
expect(await readFile("/file1.txt")).toBe("content1");
|
|
47
|
+
expect(await readFile("/file2.txt")).toBe("content2");
|
|
48
|
+
expect(await readFile("/dir/file3.txt")).toBe("content3");
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|