@webiny/api-file-manager 6.6.0-alpha.2 → 6.6.0-alpha.4

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.
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { type IAiSdkTool } from "@webiny/api-core/features/ai/index.js";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
3
  import { ListFilesUseCase } from "../../../features/file/ListFiles/index.js";
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  tag: z.ZodString;
@@ -11,8 +11,12 @@ interface ImageItem {
11
11
  type: string;
12
12
  tags: string[];
13
13
  }
14
- declare class ListImagesByTagToolImpl implements IAiSdkTool<Input> {
14
+ declare class ListImagesByTagToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
15
15
  private listFiles;
16
+ constructor(listFiles: ListFilesUseCase.Interface);
17
+ execute(input: Input): Promise<ImageItem[]>;
18
+ }
19
+ declare class ListImagesByTagToolImpl implements AiSdkToolDefinition.Interface<Input> {
16
20
  readonly name = "listImagesByTag";
17
21
  readonly title = "List images by tag";
18
22
  readonly description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
@@ -23,10 +27,11 @@ declare class ListImagesByTagToolImpl implements IAiSdkTool<Input> {
23
27
  readOnlyHint: boolean;
24
28
  idempotentHint: boolean;
25
29
  };
26
- constructor(listFiles: ListFilesUseCase.Interface);
27
- execute(input: Input): Promise<ImageItem[]>;
30
+ readonly handler: typeof ListImagesByTagToolHandlerImpl & {
31
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
32
+ };
28
33
  }
29
34
  export declare const ListImagesByTagTool: typeof ListImagesByTagToolImpl & {
30
- __abstraction: import("@webiny/di").Abstraction<IAiSdkTool<any>>;
35
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
31
36
  };
32
37
  export {};
@@ -1,20 +1,12 @@
1
1
  import { z } from "zod";
2
- import { AiSdkTool } from "@webiny/api-core/features/ai/index.js";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
3
  import { ListFilesUseCase } from "../ListFiles/index.js";
4
4
  const inputSchema = z.object({
5
5
  tag: z.string().describe("Tag to filter images by")
6
6
  });
7
- class ListImagesByTagToolImpl {
7
+ class ListImagesByTagToolHandlerImpl {
8
8
  constructor(listFiles){
9
9
  this.listFiles = listFiles;
10
- this.name = "listImagesByTag";
11
- this.title = "List images by tag";
12
- this.description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
13
- this.inputSchema = inputSchema;
14
- this.annotations = {
15
- readOnlyHint: true,
16
- idempotentHint: true
17
- };
18
10
  }
19
11
  async execute(input) {
20
12
  console.log("Call images tool", input);
@@ -36,12 +28,29 @@ class ListImagesByTagToolImpl {
36
28
  }));
37
29
  }
38
30
  }
39
- const ListImagesByTagTool = AiSdkTool.createImplementation({
40
- implementation: ListImagesByTagToolImpl,
31
+ const ListImagesByTagToolHandler = AiSdkToolHandler.createImplementation({
32
+ implementation: ListImagesByTagToolHandlerImpl,
41
33
  dependencies: [
42
34
  ListFilesUseCase
43
35
  ]
44
36
  });
37
+ class ListImagesByTagToolImpl {
38
+ constructor(){
39
+ this.name = "listImagesByTag";
40
+ this.title = "List images by tag";
41
+ this.description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
42
+ this.inputSchema = inputSchema;
43
+ this.annotations = {
44
+ readOnlyHint: true,
45
+ idempotentHint: true
46
+ };
47
+ this.handler = ListImagesByTagToolHandler;
48
+ }
49
+ }
50
+ const ListImagesByTagTool = AiSdkToolDefinition.createImplementation({
51
+ implementation: ListImagesByTagToolImpl,
52
+ dependencies: []
53
+ });
45
54
  export { ListImagesByTagTool };
46
55
 
47
56
  //# sourceMappingURL=ListImagesByTagTool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/file/ListImagesByTagTool/ListImagesByTagTool.js","sources":["../../../../src/features/file/ListImagesByTagTool/ListImagesByTagTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkTool, type IAiSdkTool } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/index.js\";\n\nconst inputSchema = z.object({\n tag: z.string().describe(\"Tag to filter images by\")\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface ImageItem {\n id: string;\n name: string;\n type: string;\n tags: string[];\n}\n\nclass ListImagesByTagToolImpl implements IAiSdkTool<Input> {\n readonly name = \"listImagesByTag\";\n readonly title = \"List images by tag\";\n readonly description =\n \"Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n\n constructor(private listFiles: ListFilesUseCase.Interface) {}\n\n async execute(input: Input): Promise<ImageItem[]> {\n console.log(\"Call images tool\", input);\n const result = await this.listFiles.execute({\n where: {\n type_startsWith: \"image/\",\n tags_in: [input.tag]\n },\n limit: 50\n });\n\n if (result.isFail()) {\n return [];\n }\n\n return result.value.items.map(file => ({\n id: file.id,\n name: file.name,\n type: file.type,\n tags: file.tags\n }));\n }\n}\n\nexport const ListImagesByTagTool = AiSdkTool.createImplementation({\n implementation: ListImagesByTagToolImpl,\n dependencies: [ListFilesUseCase]\n});\n"],"names":["inputSchema","z","ListImagesByTagToolImpl","listFiles","input","console","result","file","ListImagesByTagTool","AiSdkTool","ListFilesUseCase"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,KAAKA,EAAE,MAAM,GAAG,QAAQ,CAAC;AAC7B;AAWA,MAAMC;IAQF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;aAPX,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGH;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;IAEN;IAE5D,MAAM,QAAQI,KAAY,EAAwB;QAC9CC,QAAQ,GAAG,CAAC,oBAAoBD;QAChC,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACxC,OAAO;gBACH,iBAAiB;gBACjB,SAAS;oBAACF,MAAM,GAAG;iBAAC;YACxB;YACA,OAAO;QACX;QAEA,IAAIE,OAAO,MAAM,IACb,OAAO,EAAE;QAGb,OAAOA,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAACC,CAAAA,OAAS;gBACnC,IAAIA,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;YACnB;IACJ;AACJ;AAEO,MAAMC,sBAAsBC,UAAU,oBAAoB,CAAC;IAC9D,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC"}
1
+ {"version":3,"file":"features/file/ListImagesByTagTool/ListImagesByTagTool.js","sources":["../../../../src/features/file/ListImagesByTagTool/ListImagesByTagTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/index.js\";\n\nconst inputSchema = z.object({\n tag: z.string().describe(\"Tag to filter images by\")\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface ImageItem {\n id: string;\n name: string;\n type: string;\n tags: string[];\n}\n\nclass ListImagesByTagToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private listFiles: ListFilesUseCase.Interface) {}\n\n async execute(input: Input): Promise<ImageItem[]> {\n console.log(\"Call images tool\", input);\n const result = await this.listFiles.execute({\n where: {\n type_startsWith: \"image/\",\n tags_in: [input.tag]\n },\n limit: 50\n });\n\n if (result.isFail()) {\n return [];\n }\n\n return result.value.items.map(file => ({\n id: file.id,\n name: file.name,\n type: file.type,\n tags: file.tags\n }));\n }\n}\n\nconst ListImagesByTagToolHandler = AiSdkToolHandler.createImplementation({\n implementation: ListImagesByTagToolHandlerImpl,\n dependencies: [ListFilesUseCase]\n});\n\nclass ListImagesByTagToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"listImagesByTag\";\n readonly title = \"List images by tag\";\n readonly description =\n \"Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n readonly handler = ListImagesByTagToolHandler;\n}\n\nexport const ListImagesByTagTool = AiSdkToolDefinition.createImplementation({\n implementation: ListImagesByTagToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","ListImagesByTagToolHandlerImpl","listFiles","input","console","result","file","ListImagesByTagToolHandler","AiSdkToolHandler","ListFilesUseCase","ListImagesByTagToolImpl","ListImagesByTagTool","AiSdkToolDefinition"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,KAAKA,EAAE,MAAM,GAAG,QAAQ,CAAC;AAC7B;AAWA,MAAMC;IACF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;IAAwC;IAE5D,MAAM,QAAQC,KAAY,EAAwB;QAC9CC,QAAQ,GAAG,CAAC,oBAAoBD;QAChC,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACxC,OAAO;gBACH,iBAAiB;gBACjB,SAAS;oBAACF,MAAM,GAAG;iBAAC;YACxB;YACA,OAAO;QACX;QAEA,IAAIE,OAAO,MAAM,IACb,OAAO,EAAE;QAGb,OAAOA,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAACC,CAAAA,OAAS;gBACnC,IAAIA,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;YACnB;IACJ;AACJ;AAEA,MAAMC,6BAA6BC,iBAAiB,oBAAoB,CAAC;IACrE,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC;AAEA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGX;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;aACzD,OAAO,GAAGQ;;AACvB;AAEO,MAAMI,sBAAsBC,oBAAoB,oBAAoB,CAAC;IACxE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/SettingsInstaller/SettingsInstaller.js","sources":["../../../../src/features/settings/SettingsInstaller/SettingsInstaller.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api-core/features/serviceDiscovery/index.js\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { AppInstaller } from \"@webiny/api-core/features/tenancy/InstallTenant/index.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { UpdateSettingsUseCase } from \"~/features/settings/UpdateSettings/abstractions.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\n\nclass SettingsInstallerImpl implements AppInstaller.Interface {\n readonly alwaysRun = true;\n readonly appName = \"FileManager\";\n readonly dependsOn = [];\n\n constructor(\n private updateSettings: UpdateSettingsUseCase.Interface,\n private keyValueStore: KeyValueStore.Interface,\n private buildParams: BuildParams.Interface\n ) {}\n\n async install(): Promise<void> {\n // TODO: move this to api-core with a proper abstraction\n const manifest = await ServiceDiscovery.load();\n\n // If no records in the database, `manifest` object is empty POJO.\n // That's why the heavy `?.` usage.\n //\n // The AWS hosting type serves files from a CloudFront domain (in the manifest). The self-hosted\n // (server) hosting type has no CloudFront — files are served by the api's own `/files/*` route — so\n // fall back to the configured API origin, read from the WEBINY_API_URL build param (baked by\n // Infra.ApiUrl), not a process.env read.\n const domain =\n manifest?.api?.cloudfront?.domain ??\n this.buildParams.get<string>(\"WEBINY_API_URL\") ??\n \"\";\n\n await this.updateSettings.execute({\n srcPrefix: `${domain}/files`\n });\n }\n\n async uninstall(): Promise<void> {\n await this.keyValueStore.delete(FILE_MANAGER_GENERAL_SETTINGS);\n }\n}\n\nexport const SettingsInstaller = createImplementation({\n abstraction: AppInstaller,\n implementation: SettingsInstallerImpl,\n dependencies: [UpdateSettingsUseCase, KeyValueStore, BuildParams]\n});\n"],"names":["SettingsInstallerImpl","updateSettings","keyValueStore","buildParams","manifest","ServiceDiscovery","domain","FILE_MANAGER_GENERAL_SETTINGS","SettingsInstaller","createImplementation","AppInstaller","UpdateSettingsUseCase","KeyValueStore","BuildParams"],"mappings":";;;;;;;AAQA,MAAMA;IAKF,YACYC,cAA+C,EAC/CC,aAAsC,EACtCC,WAAkC,CAC5C;aAHUF,cAAc,GAAdA;aACAC,aAAa,GAAbA;aACAC,WAAW,GAAXA;aAPH,SAAS,GAAG;aACZ,OAAO,GAAG;aACV,SAAS,GAAG,EAAE;IAMpB;IAEH,MAAM,UAAyB;QAE3B,MAAMC,WAAW,MAAMC,iBAAiB,IAAI;QAS5C,MAAMC,SACFF,UAAU,KAAK,YAAY,UAC3B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAS,qBAC7B;QAEJ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAC9B,WAAW,GAAGE,OAAO,MAAM,CAAC;QAChC;IACJ;IAEA,MAAM,YAA2B;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAACC;IACpC;AACJ;AAEO,MAAMC,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAuBC;QAAeC;KAAY;AACrE"}
1
+ {"version":3,"file":"features/settings/SettingsInstaller/SettingsInstaller.js","sources":["../../../../src/features/settings/SettingsInstaller/SettingsInstaller.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api-core/features/serviceDiscovery/index.js\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { AppInstaller } from \"@webiny/api-core/features/tenancy/InstallTenant/index.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { UpdateSettingsUseCase } from \"~/features/settings/UpdateSettings/abstractions.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\n\nclass SettingsInstallerImpl implements AppInstaller.Interface {\n readonly alwaysRun = true;\n readonly appName = \"FileManager\";\n readonly dependsOn = [];\n\n constructor(\n private updateSettings: UpdateSettingsUseCase.Interface,\n private keyValueStore: KeyValueStore.Interface,\n private buildParams: BuildParams.Interface\n ) {}\n\n async install(): Promise<void> {\n // TODO: move this to api-core with a proper abstraction\n const manifest = await ServiceDiscovery.load();\n\n // If no records in the database, `manifest` object is empty POJO.\n // That's why the heavy `?.` usage.\n //\n // The AWS hosting type serves files from a CloudFront domain (in the manifest). The standalone\n // (server) hosting type has no CloudFront — files are served by the api's own `/files/*` route — so\n // fall back to the configured API origin, read from the WEBINY_API_URL build param (baked by\n // Infra.ApiUrl), not a process.env read.\n const domain =\n manifest?.api?.cloudfront?.domain ??\n this.buildParams.get<string>(\"WEBINY_API_URL\") ??\n \"\";\n\n await this.updateSettings.execute({\n srcPrefix: `${domain}/files`\n });\n }\n\n async uninstall(): Promise<void> {\n await this.keyValueStore.delete(FILE_MANAGER_GENERAL_SETTINGS);\n }\n}\n\nexport const SettingsInstaller = createImplementation({\n abstraction: AppInstaller,\n implementation: SettingsInstallerImpl,\n dependencies: [UpdateSettingsUseCase, KeyValueStore, BuildParams]\n});\n"],"names":["SettingsInstallerImpl","updateSettings","keyValueStore","buildParams","manifest","ServiceDiscovery","domain","FILE_MANAGER_GENERAL_SETTINGS","SettingsInstaller","createImplementation","AppInstaller","UpdateSettingsUseCase","KeyValueStore","BuildParams"],"mappings":";;;;;;;AAQA,MAAMA;IAKF,YACYC,cAA+C,EAC/CC,aAAsC,EACtCC,WAAkC,CAC5C;aAHUF,cAAc,GAAdA;aACAC,aAAa,GAAbA;aACAC,WAAW,GAAXA;aAPH,SAAS,GAAG;aACZ,OAAO,GAAG;aACV,SAAS,GAAG,EAAE;IAMpB;IAEH,MAAM,UAAyB;QAE3B,MAAMC,WAAW,MAAMC,iBAAiB,IAAI;QAS5C,MAAMC,SACFF,UAAU,KAAK,YAAY,UAC3B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAS,qBAC7B;QAEJ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAC9B,WAAW,GAAGE,OAAO,MAAM,CAAC;QAChC;IACJ;IAEA,MAAM,YAA2B;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAACC;IACpC;AACJ;AAEO,MAAMC,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAuBC;QAAeC;KAAY;AACrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager",
3
- "version": "6.6.0-alpha.2",
3
+ "version": "6.6.0-alpha.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -22,19 +22,19 @@
22
22
  ],
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@webiny/api": "6.6.0-alpha.2",
26
- "@webiny/api-core": "6.6.0-alpha.2",
27
- "@webiny/api-graphql": "6.6.0-alpha.2",
28
- "@webiny/api-headless-cms": "6.6.0-alpha.2",
29
- "@webiny/background-tasks": "6.6.0-alpha.2",
30
- "@webiny/build-tools": "6.6.0-alpha.2",
25
+ "@webiny/api": "6.6.0-alpha.4",
26
+ "@webiny/api-core": "6.6.0-alpha.4",
27
+ "@webiny/api-graphql": "6.6.0-alpha.4",
28
+ "@webiny/api-headless-cms": "6.6.0-alpha.4",
29
+ "@webiny/background-tasks": "6.6.0-alpha.4",
30
+ "@webiny/build-tools": "6.6.0-alpha.4",
31
31
  "@webiny/di": "1.1.0",
32
- "@webiny/error": "6.6.0-alpha.2",
33
- "@webiny/event-handler-core": "6.6.0-alpha.2",
34
- "@webiny/feature": "6.6.0-alpha.2",
35
- "@webiny/handler": "6.6.0-alpha.2",
36
- "@webiny/plugins": "6.6.0-alpha.2",
37
- "@webiny/wcp": "6.6.0-alpha.2",
32
+ "@webiny/error": "6.6.0-alpha.4",
33
+ "@webiny/event-handler-core": "6.6.0-alpha.4",
34
+ "@webiny/feature": "6.6.0-alpha.4",
35
+ "@webiny/handler": "6.6.0-alpha.4",
36
+ "@webiny/plugins": "6.6.0-alpha.4",
37
+ "@webiny/wcp": "6.6.0-alpha.4",
38
38
  "cache-control-parser": "2.2.0",
39
39
  "graphql": "16.14.2",
40
40
  "mime": "4.1.0",
@@ -45,9 +45,9 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/object-hash": "3.0.6",
48
- "@webiny/api-core-testing": "6.6.0-alpha.2",
49
- "@webiny/utils": "6.6.0-alpha.2",
50
- "@webiny/wcp": "6.6.0-alpha.2",
48
+ "@webiny/api-core-testing": "6.6.0-alpha.4",
49
+ "@webiny/utils": "6.6.0-alpha.4",
50
+ "@webiny/wcp": "6.6.0-alpha.4",
51
51
  "rimraf": "6.1.3",
52
52
  "typescript": "7.0.2"
53
53
  },