@webiny/api-file-manager-ddb 6.0.0-alpha.0 → 6.0.0-alpha.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/index.d.ts +3 -3
- package/index.js.map +1 -1
- package/operations/AliasesStorageOperations.js.map +1 -1
- package/operations/FilesStorageOperations.d.ts +1 -1
- package/operations/FilesStorageOperations.js.map +1 -1
- package/operations/SettingsStorageOperations.d.ts +2 -2
- package/operations/SettingsStorageOperations.js.map +1 -1
- package/operations/SystemStorageOperations.d.ts +2 -2
- package/operations/SystemStorageOperations.js.map +1 -1
- package/package.json +9 -9
- package/plugins/SettingsAttributePlugin.d.ts +2 -1
- package/plugins/SettingsAttributePlugin.js.map +1 -1
- package/plugins/SystemAttributePlugin.d.ts +2 -1
- package/plugins/SystemAttributePlugin.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
-
import { PluginCollection } from "@webiny/plugins/types";
|
|
3
|
-
import { FileManagerStorageOperations } from "@webiny/api-file-manager/types";
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
+
import type { PluginCollection } from "@webiny/plugins/types";
|
|
3
|
+
import type { FileManagerStorageOperations } from "@webiny/api-file-manager/types";
|
|
4
4
|
export interface StorageOperationsConfig {
|
|
5
5
|
documentClient: DynamoDBDocument;
|
|
6
6
|
plugins?: PluginCollection;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","_interopRequireDefault","require","_plugins2","_FilesStorageOperations","_SettingsStorageOperations","_SystemStorageOperations","_plugins3","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_AliasesStorageOperations","_api","createFileManagerStorageOperations","documentClient","plugins","userPlugins","PluginsContainer","ddbPlugins","beforeInit","context","types","SettingsAttributePlugin","type","SystemAttributePlugin","CompressorPlugin","mergeByType","files","FilesStorageOperations","aliases","AliasesStorageOperations","settings","SettingsStorageOperations","system","SystemStorageOperations"],"sources":["index.ts"],"sourcesContent":["import { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport ddbPlugins from \"@webiny/db-dynamodb/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport { FileManagerStorageOperations } from \"@webiny/api-file-manager/types\";\nimport { FilesStorageOperations } from \"~/operations/FilesStorageOperations\";\nimport { SettingsStorageOperations } from \"~/operations/SettingsStorageOperations\";\nimport { SystemStorageOperations } from \"~/operations/SystemStorageOperations\";\nimport { SettingsAttributePlugin, SystemAttributePlugin } from \"./plugins\";\nimport { AliasesStorageOperations } from \"~/operations/AliasesStorageOperations\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\nexport interface StorageOperationsConfig {\n documentClient: DynamoDBDocument;\n plugins?: PluginCollection;\n}\n\nexport * from \"./plugins\";\n\nexport const createFileManagerStorageOperations = ({\n documentClient,\n plugins: userPlugins\n}: StorageOperationsConfig): FileManagerStorageOperations => {\n const plugins = new PluginsContainer([\n ddbPlugins(),\n // User plugins\n ...(userPlugins || [])\n ]);\n\n return {\n beforeInit: async context => {\n const types: string[] = [\n SettingsAttributePlugin.type,\n SystemAttributePlugin.type,\n CompressorPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n },\n files: new FilesStorageOperations(),\n aliases: new AliasesStorageOperations({ documentClient }),\n settings: new SettingsStorageOperations({ documentClient }),\n system: new SystemStorageOperations({ documentClient })\n };\n};\n"],"mappings":";;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAGA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,wBAAA,GA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DmB,MAAM,EAAE,IAAIC,gDAAuB,CAAC;MAAEpB;IAAe,CAAC;EAC1D,CAAC;AACL,CAAC;AAACP,OAAA,CAAAM,kCAAA,GAAAA,kCAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_plugins","_interopRequireDefault","require","_plugins2","_FilesStorageOperations","_SettingsStorageOperations","_SystemStorageOperations","_plugins3","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_AliasesStorageOperations","_api","createFileManagerStorageOperations","documentClient","plugins","userPlugins","PluginsContainer","ddbPlugins","beforeInit","context","types","SettingsAttributePlugin","type","SystemAttributePlugin","CompressorPlugin","mergeByType","files","FilesStorageOperations","aliases","AliasesStorageOperations","settings","SettingsStorageOperations","system","SystemStorageOperations"],"sources":["index.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport ddbPlugins from \"@webiny/db-dynamodb/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport type { PluginCollection } from \"@webiny/plugins/types\";\nimport type { FileManagerStorageOperations } from \"@webiny/api-file-manager/types\";\nimport { FilesStorageOperations } from \"~/operations/FilesStorageOperations\";\nimport { SettingsStorageOperations } from \"~/operations/SettingsStorageOperations\";\nimport { SystemStorageOperations } from \"~/operations/SystemStorageOperations\";\nimport { SettingsAttributePlugin, SystemAttributePlugin } from \"./plugins\";\nimport { AliasesStorageOperations } from \"~/operations/AliasesStorageOperations\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\nexport interface StorageOperationsConfig {\n documentClient: DynamoDBDocument;\n plugins?: PluginCollection;\n}\n\nexport * from \"./plugins\";\n\nexport const createFileManagerStorageOperations = ({\n documentClient,\n plugins: userPlugins\n}: StorageOperationsConfig): FileManagerStorageOperations => {\n const plugins = new PluginsContainer([\n ddbPlugins(),\n // User plugins\n ...(userPlugins || [])\n ]);\n\n return {\n beforeInit: async context => {\n const types: string[] = [\n SettingsAttributePlugin.type,\n SystemAttributePlugin.type,\n CompressorPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n },\n files: new FilesStorageOperations(),\n aliases: new AliasesStorageOperations({ documentClient }),\n settings: new SettingsStorageOperations({ documentClient }),\n system: new SystemStorageOperations({ documentClient })\n };\n};\n"],"mappings":";;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAGA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,wBAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AASAM,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,SAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,SAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AARA,IAAAS,yBAAA,GAAAlB,OAAA;AACA,IAAAmB,IAAA,GAAAnB,OAAA;AASO,MAAMoB,kCAAkC,GAAGA,CAAC;EAC/CC,cAAc;EACdC,OAAO,EAAEC;AACY,CAAC,KAAmC;EACzD,MAAMD,OAAO,GAAG,IAAIE,0BAAgB,CAAC,CACjC,IAAAC,gBAAU,EAAC,CAAC;EACZ;EACA,IAAIF,WAAW,IAAI,EAAE,CAAC,CACzB,CAAC;EAEF,OAAO;IACHG,UAAU,EAAE,MAAMC,OAAO,IAAI;MACzB,MAAMC,KAAe,GAAG,CACpBC,iCAAuB,CAACC,IAAI,EAC5BC,+BAAqB,CAACD,IAAI,EAC1BE,qBAAgB,CAACF,IAAI,CACxB;MACD,KAAK,MAAMA,IAAI,IAAIF,KAAK,EAAE;QACtBN,OAAO,CAACW,WAAW,CAACN,OAAO,CAACL,OAAO,EAAEQ,IAAI,CAAC;MAC9C;IACJ,CAAC;IACDI,KAAK,EAAE,IAAIC,8CAAsB,CAAC,CAAC;IACnCC,OAAO,EAAE,IAAIC,kDAAwB,CAAC;MAAEhB;IAAe,CAAC,CAAC;IACzDiB,QAAQ,EAAE,IAAIC,oDAAyB,CAAC;MAAElB;IAAe,CAAC,CAAC;IAC3DmB,MAAM,EAAE,IAAIC,gDAAuB,CAAC;MAAEpB;IAAe,CAAC;EAC1D,CAAC;AACL,CAAC;AAACP,OAAA,CAAAM,kCAAA,GAAAA,kCAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dbDynamodb","require","AliasesStorageOperations","constructor","documentClient","table","createTable","aliasEntity","createStandardEntity","name","deleteAliases","file","aliasItems","getExistingAliases","batchWrite","createEntityWriteBatch","entity","delete","map","item","PK","createPartitionKey","id","fileId","tenant","locale","SK","alias","execute","storeAliases","existingAliases","newAliases","createNewAliasesRecords","put","data","aliases","some","queryAll","partitionKey","options","beginsWith","params","find","GSI1_PK","GSI1_SK","TYPE","key","filter","Boolean","exports"],"sources":["AliasesStorageOperations.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type {\n File,\n FileAlias,\n FileManagerAliasesStorageOperations\n} from \"@webiny/api-file-manager/types\";\nimport {\n createEntityWriteBatch,\n createStandardEntity,\n createTable,\n
|
|
1
|
+
{"version":3,"names":["_dbDynamodb","require","AliasesStorageOperations","constructor","documentClient","table","createTable","aliasEntity","createStandardEntity","name","deleteAliases","file","aliasItems","getExistingAliases","batchWrite","createEntityWriteBatch","entity","delete","map","item","PK","createPartitionKey","id","fileId","tenant","locale","SK","alias","execute","storeAliases","existingAliases","newAliases","createNewAliasesRecords","put","data","aliases","some","queryAll","partitionKey","options","beginsWith","params","find","GSI1_PK","GSI1_SK","TYPE","key","filter","Boolean","exports"],"sources":["AliasesStorageOperations.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type {\n File,\n FileAlias,\n FileManagerAliasesStorageOperations\n} from \"@webiny/api-file-manager/types\";\nimport type { DbItem } from \"@webiny/db-dynamodb\";\nimport {\n createEntityWriteBatch,\n createStandardEntity,\n createTable,\n queryAll\n} from \"@webiny/db-dynamodb\";\n\ninterface AliasesStorageOperationsConfig {\n documentClient: DynamoDBDocument;\n}\n\ninterface CreatePartitionKeyParams {\n locale: string;\n tenant: string;\n id: string;\n}\n\nexport class AliasesStorageOperations implements FileManagerAliasesStorageOperations {\n private readonly aliasEntity: Entity<any>;\n private readonly table: Table<string, string, string>;\n\n constructor({ documentClient }: AliasesStorageOperationsConfig) {\n this.table = createTable({ documentClient });\n\n this.aliasEntity = createStandardEntity({\n table: this.table,\n name: \"FM.FileAlias\"\n });\n }\n\n async deleteAliases(file: File): Promise<void> {\n const aliasItems = await this.getExistingAliases(file);\n\n const batchWrite = createEntityWriteBatch({\n entity: this.aliasEntity,\n delete: aliasItems.map(item => {\n return {\n PK: this.createPartitionKey({\n id: item.fileId,\n tenant: item.tenant,\n locale: item.locale\n }),\n SK: `ALIAS#${item.alias}`\n };\n })\n });\n\n await batchWrite.execute();\n }\n\n async storeAliases(file: File): Promise<void> {\n const existingAliases = await this.getExistingAliases(file);\n const newAliases = this.createNewAliasesRecords(file, existingAliases);\n\n const batchWrite = createEntityWriteBatch({\n entity: this.aliasEntity\n });\n for (const alias of newAliases) {\n batchWrite.put(alias);\n }\n\n // Delete aliases that are in the DB but are NOT in the file.\n for (const data of existingAliases) {\n if (!file.aliases.some(alias => data.alias === alias)) {\n batchWrite.delete({\n PK: this.createPartitionKey(file),\n SK: `ALIAS#${data.alias}`\n });\n }\n }\n\n await batchWrite.execute();\n }\n\n private async getExistingAliases(file: File): Promise<FileAlias[]> {\n const aliases = await queryAll<{ data: FileAlias }>({\n entity: this.aliasEntity,\n partitionKey: this.createPartitionKey(file),\n options: {\n beginsWith: \"ALIAS#\"\n }\n });\n\n return aliases.map(alias => alias.data);\n }\n\n private createPartitionKey(params: CreatePartitionKeyParams): string {\n const { tenant, locale, id } = params;\n return `T#${tenant}#L#${locale}#FM#F${id}`;\n }\n\n private createNewAliasesRecords(\n file: File,\n existingAliases: FileAlias[] = []\n ): DbItem<FileAlias>[] {\n return (file.aliases || [])\n .map(alias => {\n // If alias is already in the DB, skip it.\n if (existingAliases.find(item => item.alias === alias)) {\n return null;\n }\n\n // Add a new alias.\n return {\n PK: this.createPartitionKey(file),\n SK: `ALIAS#${alias}`,\n GSI1_PK: `T#${file.tenant}#FM#FILE_ALIASES`,\n GSI1_SK: alias,\n TYPE: \"fm.fileAlias\",\n data: {\n alias,\n tenant: file.tenant,\n locale: file.locale,\n fileId: file.id,\n key: file.key\n }\n };\n })\n .filter(Boolean) as DbItem<FileAlias>[];\n }\n}\n"],"mappings":";;;;;;AAQA,IAAAA,WAAA,GAAAC,OAAA;AAiBO,MAAMC,wBAAwB,CAAgD;EAIjFC,WAAWA,CAAC;IAAEC;EAA+C,CAAC,EAAE;IAC5D,IAAI,CAACC,KAAK,GAAG,IAAAC,uBAAW,EAAC;MAAEF;IAAe,CAAC,CAAC;IAE5C,IAAI,CAACG,WAAW,GAAG,IAAAC,gCAAoB,EAAC;MACpCH,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBI,IAAI,EAAE;IACV,CAAC,CAAC;EACN;EAEA,MAAMC,aAAaA,CAACC,IAAU,EAAiB;IAC3C,MAAMC,UAAU,GAAG,MAAM,IAAI,CAACC,kBAAkB,CAACF,IAAI,CAAC;IAEtD,MAAMG,UAAU,GAAG,IAAA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ACJ;AAACC,OAAA,CAAA/C,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { File, FileManagerFilesStorageOperations, FileManagerFilesStorageOperationsListResponse, FileManagerFilesStorageOperationsTagsResponse } from "@webiny/api-file-manager/types";
|
|
1
|
+
import type { File, FileManagerFilesStorageOperations, FileManagerFilesStorageOperationsListResponse, FileManagerFilesStorageOperationsTagsResponse } from "@webiny/api-file-manager/types";
|
|
2
2
|
/**
|
|
3
3
|
* This class is here to satisfy TS interface, but it will always be overridden by CMS storage operations
|
|
4
4
|
* within the `api-file-manager` package itself. This will remain here until we find a better approach to organizing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FilesStorageOperations","create","Error","createBatch","delete","get","list","tags","update","exports"],"sources":["FilesStorageOperations.ts"],"sourcesContent":["import {\n File,\n FileManagerFilesStorageOperations,\n FileManagerFilesStorageOperationsListResponse,\n FileManagerFilesStorageOperationsTagsResponse\n} from \"@webiny/api-file-manager/types\";\n\n/**\n * This class is here to satisfy TS interface, but it will always be overridden by CMS storage operations\n * within the `api-file-manager` package itself. This will remain here until we find a better approach to organizing\n * storage operations, and connecting app logic to CMS.\n */\nexport class FilesStorageOperations implements FileManagerFilesStorageOperations {\n create(): Promise<File> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n createBatch(): Promise<File[]> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n delete(): Promise<void> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n get(): Promise<File | null> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n list(): Promise<FileManagerFilesStorageOperationsListResponse> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n tags(): Promise<FileManagerFilesStorageOperationsTagsResponse[]> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n update(): Promise<File> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n}\n"],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA;AACO,MAAMA,sBAAsB,CAA8C;EAC7EC,MAAMA,CAAA,EAAkB;IACpB,MAAM,IAAIC,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAC,WAAWA,CAAA,EAAoB;IAC3B,MAAM,IAAID,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAE,MAAMA,CAAA,EAAkB;IACpB,MAAM,IAAIF,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAG,GAAGA,CAAA,EAAyB;IACxB,MAAM,IAAIH,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAI,IAAIA,CAAA,EAA2D;IAC3D,MAAM,IAAIJ,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAK,IAAIA,CAAA,EAA6D;IAC7D,MAAM,IAAIL,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAM,MAAMA,CAAA,EAAkB;IACpB,MAAM,IAAIN,KAAK,CAAC,uEAAuE,CAAC;EAC5F;AACJ;AAACO,OAAA,CAAAT,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["FilesStorageOperations","create","Error","createBatch","delete","get","list","tags","update","exports"],"sources":["FilesStorageOperations.ts"],"sourcesContent":["import type {\n File,\n FileManagerFilesStorageOperations,\n FileManagerFilesStorageOperationsListResponse,\n FileManagerFilesStorageOperationsTagsResponse\n} from \"@webiny/api-file-manager/types\";\n\n/**\n * This class is here to satisfy TS interface, but it will always be overridden by CMS storage operations\n * within the `api-file-manager` package itself. This will remain here until we find a better approach to organizing\n * storage operations, and connecting app logic to CMS.\n */\nexport class FilesStorageOperations implements FileManagerFilesStorageOperations {\n create(): Promise<File> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n createBatch(): Promise<File[]> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n delete(): Promise<void> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n get(): Promise<File | null> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n list(): Promise<FileManagerFilesStorageOperationsListResponse> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n tags(): Promise<FileManagerFilesStorageOperationsTagsResponse[]> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n\n update(): Promise<File> {\n throw new Error(\"api-file-manager-ddb does not implement the Files storage operations.\");\n }\n}\n"],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA;AACO,MAAMA,sBAAsB,CAA8C;EAC7EC,MAAMA,CAAA,EAAkB;IACpB,MAAM,IAAIC,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAC,WAAWA,CAAA,EAAoB;IAC3B,MAAM,IAAID,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAE,MAAMA,CAAA,EAAkB;IACpB,MAAM,IAAIF,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAG,GAAGA,CAAA,EAAyB;IACxB,MAAM,IAAIH,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAI,IAAIA,CAAA,EAA2D;IAC3D,MAAM,IAAIJ,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAK,IAAIA,CAAA,EAA6D;IAC7D,MAAM,IAAIL,KAAK,CAAC,uEAAuE,CAAC;EAC5F;EAEAM,MAAMA,CAAA,EAAkB;IACpB,MAAM,IAAIN,KAAK,CAAC,uEAAuE,CAAC;EAC5F;AACJ;AAACO,OAAA,CAAAT,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
-
import { FileManagerSettings, FileManagerSettingsStorageOperations, FileManagerSettingsStorageOperationsCreateParams, FileManagerSettingsStorageOperationsUpdateParams, FileManagerStorageOperationsDeleteSettings, FileManagerStorageOperationsGetSettingsParams } from "@webiny/api-file-manager/types";
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
+
import type { FileManagerSettings, FileManagerSettingsStorageOperations, FileManagerSettingsStorageOperationsCreateParams, FileManagerSettingsStorageOperationsUpdateParams, FileManagerStorageOperationsDeleteSettings, FileManagerStorageOperationsGetSettingsParams } from "@webiny/api-file-manager/types";
|
|
3
3
|
interface SettingsStorageOperationsConfig {
|
|
4
4
|
documentClient: DynamoDBDocument;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_dbDynamodb","SORT_KEY","SettingsStorageOperations","constructor","documentClient","_entity","createStandardEntity","table","createTable","name","get","tenant","settings","entity","keys","PK","SK","data","ex","WebinyError","message","code","create","original","update","put","item","TYPE","delete","deleteItem","exports"],"sources":["SettingsStorageOperations.ts"],"sourcesContent":["import { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport {\n FileManagerSettings,\n FileManagerSettingsStorageOperations,\n FileManagerSettingsStorageOperationsCreateParams,\n FileManagerSettingsStorageOperationsUpdateParams,\n FileManagerStorageOperationsDeleteSettings,\n FileManagerStorageOperationsGetSettingsParams\n} from \"@webiny/api-file-manager/types\";\nimport WebinyError from \"@webiny/error\";\nimport { createStandardEntity, createTable, deleteItem, get, put } from \"@webiny/db-dynamodb\";\n\ninterface SettingsStorageOperationsConfig {\n documentClient: DynamoDBDocument;\n}\n\nconst SORT_KEY = \"A\";\n\nexport class SettingsStorageOperations implements FileManagerSettingsStorageOperations {\n private readonly _entity: Entity<any>;\n\n public constructor({ documentClient }: SettingsStorageOperationsConfig) {\n this._entity = createStandardEntity({\n table: createTable({ documentClient }),\n name: \"FM.Settings\"\n });\n }\n\n public async get({\n tenant\n }: FileManagerStorageOperationsGetSettingsParams): Promise<FileManagerSettings | null> {\n try {\n const settings = await get<{ data: FileManagerSettings }>({\n entity: this._entity,\n keys: {\n PK: `T#${tenant}#FM#SETTINGS`,\n SK: SORT_KEY\n }\n });\n\n return settings?.data || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager settings.\",\n ex.code || \"GET_SETTINGS_ERROR\"\n );\n }\n }\n\n public async create({\n data\n }: FileManagerSettingsStorageOperationsCreateParams): Promise<FileManagerSettings> {\n const original = await this.get({ tenant: data.tenant });\n\n if (original) {\n return await this.update({ original, data });\n }\n\n try {\n await put({\n entity: this._entity,\n item: {\n PK: `T#${data.tenant}#FM#SETTINGS`,\n SK: SORT_KEY,\n TYPE: \"fm.settings\",\n data\n }\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot create FileManager settings.\",\n ex.code || \"CREATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async update({\n data\n }: FileManagerSettingsStorageOperationsUpdateParams): Promise<FileManagerSettings> {\n try {\n await put({\n entity: this._entity,\n item: {\n PK: `T#${data.tenant}#FM#SETTINGS`,\n SK: SORT_KEY,\n TYPE: \"fm.settings\",\n data\n }\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot update FileManager settings.\",\n ex.code || \"UPDATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async delete({ tenant }: FileManagerStorageOperationsDeleteSettings): Promise<void> {\n await deleteItem({\n entity: this._entity,\n keys: {\n PK: `T#${tenant}#FM#SETTINGS`,\n SK: SORT_KEY\n }\n });\n }\n}\n"],"mappings":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,MAAME,QAAQ,GAAG,GAAG;AAEb,MAAMC,yBAAyB,CAAiD;EAG5EC,WAAWA,CAAC;IAAEC;EAAgD,CAAC,EAAE;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AI,qCAAqC,EACnDF,EAAE,CAACG,IAAI,IAAI,0BAA0B,EACrC;QACIJ;MACJ,CACJ,CAAC;IACL;EACJ;EAEA,MAAaO,MAAMA,CAAC;IAChBP;EAC8C,CAAC,EAAgC;IAC/E,IAAI;MACA,MAAM,IAAAQ,eAAG,EAAC;QACNZ,MAAM,EAAE,IAAI,CAACR,OAAO;QACpBqB,IAAI,EAAE;UACFX,EAAE,EAAE,KAAKE,IAAI,CAACN,MAAM,cAAc;UAClCK,EAAE,EAAEf,QAAQ;UACZ0B,IAAI,EAAE,aAAa;UACnBV;QACJ;MACJ,CAAC,CAAC;MACF,OAAOA,IAAI;IACf,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,qCAAqC,EACnDF,EAAE,CAACG,IAAI,IAAI,0BAA0B,EACrC;QACIJ;MACJ,CACJ,CAAC;IACL;EACJ;EAEA,MAAaW,MAAMA,CAAC;IAAEjB;EAAmD,CAAC,EAAiB;IACvF,MAAM,IAAAkB,sBAAU,EAAC;MACbhB,MAAM,EAAE,IAAI,CAACR,OAAO;MACpBS,IAAI,EAAE;QACFC,EAAE,EAAE,KAAKJ,MAAM,cAAc;QAC7BK,EAAE,EAAEf;MACR;IACJ,CAAC,CAAC;EACN;AACJ;AAAC6B,OAAA,CAAA5B,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_dbDynamodb","SORT_KEY","SettingsStorageOperations","constructor","documentClient","_entity","createStandardEntity","table","createTable","name","get","tenant","settings","entity","keys","PK","SK","data","ex","WebinyError","message","code","create","original","update","put","item","TYPE","delete","deleteItem","exports"],"sources":["SettingsStorageOperations.ts"],"sourcesContent":["import type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type {\n FileManagerSettings,\n FileManagerSettingsStorageOperations,\n FileManagerSettingsStorageOperationsCreateParams,\n FileManagerSettingsStorageOperationsUpdateParams,\n FileManagerStorageOperationsDeleteSettings,\n FileManagerStorageOperationsGetSettingsParams\n} from \"@webiny/api-file-manager/types\";\nimport WebinyError from \"@webiny/error\";\nimport { createStandardEntity, createTable, deleteItem, get, put } from \"@webiny/db-dynamodb\";\n\ninterface SettingsStorageOperationsConfig {\n documentClient: DynamoDBDocument;\n}\n\nconst SORT_KEY = \"A\";\n\nexport class SettingsStorageOperations implements FileManagerSettingsStorageOperations {\n private readonly _entity: Entity<any>;\n\n public constructor({ documentClient }: SettingsStorageOperationsConfig) {\n this._entity = createStandardEntity({\n table: createTable({ documentClient }),\n name: \"FM.Settings\"\n });\n }\n\n public async get({\n tenant\n }: FileManagerStorageOperationsGetSettingsParams): Promise<FileManagerSettings | null> {\n try {\n const settings = await get<{ data: FileManagerSettings }>({\n entity: this._entity,\n keys: {\n PK: `T#${tenant}#FM#SETTINGS`,\n SK: SORT_KEY\n }\n });\n\n return settings?.data || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager settings.\",\n ex.code || \"GET_SETTINGS_ERROR\"\n );\n }\n }\n\n public async create({\n data\n }: FileManagerSettingsStorageOperationsCreateParams): Promise<FileManagerSettings> {\n const original = await this.get({ tenant: data.tenant });\n\n if (original) {\n return await this.update({ original, data });\n }\n\n try {\n await put({\n entity: this._entity,\n item: {\n PK: `T#${data.tenant}#FM#SETTINGS`,\n SK: SORT_KEY,\n TYPE: \"fm.settings\",\n data\n }\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot create FileManager settings.\",\n ex.code || \"CREATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async update({\n data\n }: FileManagerSettingsStorageOperationsUpdateParams): Promise<FileManagerSettings> {\n try {\n await put({\n entity: this._entity,\n item: {\n PK: `T#${data.tenant}#FM#SETTINGS`,\n SK: SORT_KEY,\n TYPE: \"fm.settings\",\n data\n }\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot update FileManager settings.\",\n ex.code || \"UPDATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async delete({ tenant }: FileManagerStorageOperationsDeleteSettings): Promise<void> {\n await deleteItem({\n entity: this._entity,\n keys: {\n PK: `T#${tenant}#FM#SETTINGS`,\n SK: SORT_KEY\n }\n });\n }\n}\n"],"mappings":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,MAAME,QAAQ,GAAG,GAAG;AAEb,MAAMC,yBAAyB,CAAiD;EAG5EC,WAAWA,CAAC;IAAEC;EAAgD,CAAC,EAAE;IACpE,IAAI,CAACC,OAAO,GAAG,IAAAC,gCAAoB,EAAC;MAChCC,KAAK,EAAE,IAAAC,uBAAW,EAAC;QAAEJ;MAAe,CAAC,CAAC;MACtCK,IAAI,EAAE;IACV,CAAC,CAAC;EACN;EAEA,MAAaC,GAAGA,CAAC;IACbC;EAC2C,CAAC,EAAuC;IACnF,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAAF,eAAG,EAAgC;QACtDG,MAAM,EAAE,IAAI,CAACR,OAAO;QACpBS,IAAI,EAAE;UACFC,EAAE,EAAE,KAAKJ,MAAM,cAAc;UAC7BK,EAAE,EAAEf;QACR;MACJ,CAAC,CAAC;MAEF,OAAOW,QAAQ,EAAEK,IAAI,IAAI,IAAI;IACjC,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,2CAA2C,EACzDF,EAAE,CAACG,IAAI,IAAI,oBACf,CAAC;IACL;EACJ;EAEA,MAAaC,MAAMA,CAAC;IAChBL;EAC8C,CAAC,EAAgC;IAC/E,MAAMM,QAAQ,GAAG,MAAM,IAAI,CAACb,GAAG,CAAC;MAAEC,MAAM,EAAEM,IAAI,CAACN;I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,cAAc;QAC7BK,EAAE,EAAEf;MACR;IACJ,CAAC,CAAC;EACN;AACJ;AAAC6B,OAAA,CAAA5B,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
-
import { FileManagerSystem, FileManagerSystemStorageOperations, FileManagerSystemStorageOperationsCreateParams, FileManagerSystemStorageOperationsGetParams, FileManagerSystemStorageOperationsUpdateParams } from "@webiny/api-file-manager/types";
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
+
import type { FileManagerSystem, FileManagerSystemStorageOperations, FileManagerSystemStorageOperationsCreateParams, FileManagerSystemStorageOperationsGetParams, FileManagerSystemStorageOperationsUpdateParams } from "@webiny/api-file-manager/types";
|
|
3
3
|
interface SystemStorageOperationsConstructorParams {
|
|
4
4
|
documentClient: DynamoDBDocument;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_dbDynamodb","SORT_KEY","SystemStorageOperations","constructor","documentClient","_entity","createLegacyEntity","table","createTable","name","attributes","version","type","tenant","get","system","entity","keys","PK","SK","ex","WebinyError","message","code","create","params","data","put","item","update","original","exports"],"sources":["SystemStorageOperations.ts"],"sourcesContent":["import { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport {\n FileManagerSystem,\n FileManagerSystemStorageOperations,\n FileManagerSystemStorageOperationsCreateParams,\n FileManagerSystemStorageOperationsGetParams,\n FileManagerSystemStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport WebinyError from \"@webiny/error\";\nimport { createLegacyEntity, createTable, get, put } from \"@webiny/db-dynamodb\";\n\ninterface SystemStorageOperationsConstructorParams {\n documentClient: DynamoDBDocument;\n}\n\nconst SORT_KEY = \"FM\";\n\nexport class SystemStorageOperations implements FileManagerSystemStorageOperations {\n private readonly _entity: Entity<any>;\n\n public constructor({ documentClient }: SystemStorageOperationsConstructorParams) {\n this._entity = createLegacyEntity({\n table: createTable({ documentClient }),\n name: \"System\",\n attributes: {\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n }\n }\n });\n }\n\n public async get({\n tenant\n }: FileManagerSystemStorageOperationsGetParams): Promise<FileManagerSystem | null> {\n try {\n const system = await get<FileManagerSystem>({\n entity: this._entity,\n keys: {\n PK: `T#${tenant}#SYSTEM`,\n SK: SORT_KEY\n }\n });\n return system || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager system.\",\n ex.code || \"GET_SYSTEM_ERROR\"\n );\n }\n }\n\n public async create(\n params: FileManagerSystemStorageOperationsCreateParams\n ): Promise<FileManagerSystem> {\n const { data } = params;\n try {\n await put({\n entity: this._entity,\n item: {\n ...data,\n PK: `T#${data.tenant}#SYSTEM`,\n SK: SORT_KEY\n }\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not insert new system data into DynamoDB\",\n \"CREATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return data;\n }\n\n public async update(\n params: FileManagerSystemStorageOperationsUpdateParams\n ): Promise<FileManagerSystem> {\n const { original, data } = params;\n\n try {\n await put({\n entity: this._entity,\n item: {\n ...data,\n PK: `T#${data.tenant}#SYSTEM`,\n SK: SORT_KEY\n }\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not update system data in the DynamoDB.\",\n \"UPDATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return {\n ...original,\n ...data\n };\n }\n}\n"],"mappings":";;;;;;;AASA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,MAAME,QAAQ,GAAG,IAAI;AAEd,MAAMC,uBAAuB,CAA+C;EAGxEC,WAAWA,CAAC;IAAEC;EAAyD,CAAC,EAAE;IAC7E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EJ;IAAK,CAAC,GAAGD,MAAM;IAEjC,IAAI;MACA,MAAM,IAAAE,eAAG,EAAC;QACNX,MAAM,EAAE,IAAI,CAACX,OAAO;QACpBuB,IAAI,EAAE;UACF,GAAGF,IAAI;UACPR,EAAE,EAAE,KAAKQ,IAAI,CAACb,MAAM,SAAS;UAC7BM,EAAE,EAAElB;QACR;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOmB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjB,+CAA+C,EAC/C,qBAAqB,EACrB;QACIK;MACJ,CACJ,CAAC;IACL;IACA,OAAO;MACH,GAAGI,QAAQ;MACX,GAAGJ;IACP,CAAC;EACL;AACJ;AAACK,OAAA,CAAA7B,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_dbDynamodb","SORT_KEY","SystemStorageOperations","constructor","documentClient","_entity","createLegacyEntity","table","createTable","name","attributes","version","type","tenant","get","system","entity","keys","PK","SK","ex","WebinyError","message","code","create","params","data","put","item","update","original","exports"],"sources":["SystemStorageOperations.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type {\n FileManagerSystem,\n FileManagerSystemStorageOperations,\n FileManagerSystemStorageOperationsCreateParams,\n FileManagerSystemStorageOperationsGetParams,\n FileManagerSystemStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport WebinyError from \"@webiny/error\";\nimport { createLegacyEntity, createTable, get, put } from \"@webiny/db-dynamodb\";\n\ninterface SystemStorageOperationsConstructorParams {\n documentClient: DynamoDBDocument;\n}\n\nconst SORT_KEY = \"FM\";\n\nexport class SystemStorageOperations implements FileManagerSystemStorageOperations {\n private readonly _entity: Entity<any>;\n\n public constructor({ documentClient }: SystemStorageOperationsConstructorParams) {\n this._entity = createLegacyEntity({\n table: createTable({ documentClient }),\n name: \"System\",\n attributes: {\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n }\n }\n });\n }\n\n public async get({\n tenant\n }: FileManagerSystemStorageOperationsGetParams): Promise<FileManagerSystem | null> {\n try {\n const system = await get<FileManagerSystem>({\n entity: this._entity,\n keys: {\n PK: `T#${tenant}#SYSTEM`,\n SK: SORT_KEY\n }\n });\n return system || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager system.\",\n ex.code || \"GET_SYSTEM_ERROR\"\n );\n }\n }\n\n public async create(\n params: FileManagerSystemStorageOperationsCreateParams\n ): Promise<FileManagerSystem> {\n const { data } = params;\n try {\n await put({\n entity: this._entity,\n item: {\n ...data,\n PK: `T#${data.tenant}#SYSTEM`,\n SK: SORT_KEY\n }\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not insert new system data into DynamoDB\",\n \"CREATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return data;\n }\n\n public async update(\n params: FileManagerSystemStorageOperationsUpdateParams\n ): Promise<FileManagerSystem> {\n const { original, data } = params;\n\n try {\n await put({\n entity: this._entity,\n item: {\n ...data,\n PK: `T#${data.tenant}#SYSTEM`,\n SK: SORT_KEY\n }\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not update system data in the DynamoDB.\",\n \"UPDATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return {\n ...original,\n ...data\n };\n }\n}\n"],"mappings":";;;;;;;AASA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,MAAME,QAAQ,GAAG,IAAI;AAEd,MAAMC,uBAAuB,CAA+C;EAGxEC,WAAWA,CAAC;IAAEC;EAAyD,CAAC,EAAE;IAC7E,IAAI,CAACC,OAAO,GAAG,IAAAC,8BAAkB,EAAC;MAC9BC,KAAK,EAAE,IAAAC,uBAAW,EAAC;QAAEJ;MAAe,CAAC,CAAC;MACtCK,IAAI,EAAE,QAAQ;MACdC,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;UACPR,EAAE,EAAE,KAAKQ,IAAI,CAACb,MAAM,SAAS;UAC7BM,EAAE,EAAElB;QACR;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOmB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjB,+CAA+C,EAC/C,qBAAqB,EACrB;QACIK;MACJ,CACJ,CAAC;IACL;IACA,OAAO;MACH,GAAGI,QAAQ;MACX,GAAGJ;IACP,CAAC;EACL;AACJ;AAACK,OAAA,CAAA7B,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager-ddb",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-file-manager",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
],
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@webiny/api": "6.0.0-alpha.
|
|
24
|
-
"@webiny/api-file-manager": "6.0.0-alpha.
|
|
25
|
-
"@webiny/aws-sdk": "6.0.0-alpha.
|
|
26
|
-
"@webiny/db-dynamodb": "6.0.0-alpha.
|
|
27
|
-
"@webiny/error": "6.0.0-alpha.
|
|
28
|
-
"@webiny/plugins": "6.0.0-alpha.
|
|
29
|
-
"@webiny/project-utils": "6.0.0-alpha.
|
|
23
|
+
"@webiny/api": "6.0.0-alpha.1",
|
|
24
|
+
"@webiny/api-file-manager": "6.0.0-alpha.1",
|
|
25
|
+
"@webiny/aws-sdk": "6.0.0-alpha.1",
|
|
26
|
+
"@webiny/db-dynamodb": "6.0.0-alpha.1",
|
|
27
|
+
"@webiny/error": "6.0.0-alpha.1",
|
|
28
|
+
"@webiny/plugins": "6.0.0-alpha.1",
|
|
29
|
+
"@webiny/project-utils": "6.0.0-alpha.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"jest": "29.7.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
]
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "9bd236cf5e689f209a11bec089207dcc2d41a53c"
|
|
57
57
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AttributePluginParams } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
|
|
2
|
+
import { AttributePlugin } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
|
|
2
3
|
export declare class SettingsAttributePlugin extends AttributePlugin {
|
|
3
4
|
constructor(params: Omit<AttributePluginParams, "entity">);
|
|
4
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_AttributePlugin","require","SettingsAttributePlugin","AttributePlugin","constructor","params","entity","exports"],"sources":["SettingsAttributePlugin.ts"],"sourcesContent":["import {\
|
|
1
|
+
{"version":3,"names":["_AttributePlugin","require","SettingsAttributePlugin","AttributePlugin","constructor","params","entity","exports"],"sources":["SettingsAttributePlugin.ts"],"sourcesContent":["import type { AttributePluginParams } from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\nimport { AttributePlugin } from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class SettingsAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"FM.Settings\"\n });\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAEO,MAAMC,uBAAuB,SAASC,gCAAe,CAAC;EAClDC,WAAWA,CAACC,MAA6C,EAAE;IAC9D,KAAK,CAAC;MACF,GAAGA,MAAM;MACTC,MAAM,EAAE;IACZ,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAL,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AttributePluginParams } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
|
|
2
|
+
import { AttributePlugin } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
|
|
2
3
|
export declare class SystemAttributePlugin extends AttributePlugin {
|
|
3
4
|
constructor(params: Omit<AttributePluginParams, "entity">);
|
|
4
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_AttributePlugin","require","SystemAttributePlugin","AttributePlugin","constructor","params","entity","exports"],"sources":["SystemAttributePlugin.ts"],"sourcesContent":["import {\
|
|
1
|
+
{"version":3,"names":["_AttributePlugin","require","SystemAttributePlugin","AttributePlugin","constructor","params","entity","exports"],"sources":["SystemAttributePlugin.ts"],"sourcesContent":["import type { AttributePluginParams } from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\nimport { AttributePlugin } from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class SystemAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"System\"\n });\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAEO,MAAMC,qBAAqB,SAASC,gCAAe,CAAC;EAChDC,WAAWA,CAACC,MAA6C,EAAE;IAC9D,KAAK,CAAC;MACF,GAAGA,MAAM;MACTC,MAAM,EAAE;IACZ,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAL,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|