@webiny/api-aco-sql 6.6.0-alpha.10 → 6.6.0-alpha.12

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.
@@ -0,0 +1,13 @@
1
+ import { KnexClient, SqlSchemaConfig, SqlSchemaSetup } from "@webiny/api-core-sql";
2
+ /** The `aco` schema setup step: the folder-level permissions table. */
3
+ declare class AcoSqlSchemaSetupImpl implements SqlSchemaSetup.Interface {
4
+ private readonly knex;
5
+ private readonly schemaConfig?;
6
+ readonly name = "aco";
7
+ constructor(knex: KnexClient.Interface, schemaConfig?: SqlSchemaConfig.Interface | undefined);
8
+ setup(): Promise<void>;
9
+ }
10
+ export declare const AcoSqlSchemaSetup: typeof AcoSqlSchemaSetupImpl & {
11
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core-sql/schemaSetup/abstractions.js").ISqlSchemaSetup>;
12
+ };
13
+ export {};
@@ -0,0 +1,31 @@
1
+ import { KnexClient, SqlSchemaConfig, SqlSchemaSetup } from "@webiny/api-core-sql";
2
+ import { FolderLevelPermissionsStorageOperations } from "./FolderLevelPermissionsStorageOperations.js";
3
+ class AcoSqlSchemaSetupImpl {
4
+ constructor(knex, schemaConfig){
5
+ this.knex = knex;
6
+ this.schemaConfig = schemaConfig;
7
+ this.name = "aco";
8
+ }
9
+ setup() {
10
+ const operations = new FolderLevelPermissionsStorageOperations({
11
+ knex: this.knex.client,
12
+ tableNamePrefix: this.schemaConfig?.tableNamePrefix
13
+ });
14
+ return operations.setupSchema();
15
+ }
16
+ }
17
+ const AcoSqlSchemaSetup = SqlSchemaSetup.createImplementation({
18
+ implementation: AcoSqlSchemaSetupImpl,
19
+ dependencies: [
20
+ KnexClient,
21
+ [
22
+ SqlSchemaConfig,
23
+ {
24
+ optional: true
25
+ }
26
+ ]
27
+ ]
28
+ });
29
+ export { AcoSqlSchemaSetup };
30
+
31
+ //# sourceMappingURL=AcoSqlSchemaSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcoSqlSchemaSetup.js","sources":["../src/AcoSqlSchemaSetup.ts"],"sourcesContent":["import { KnexClient, SqlSchemaConfig, SqlSchemaSetup } from \"@webiny/api-core-sql\";\nimport { FolderLevelPermissionsStorageOperations } from \"./FolderLevelPermissionsStorageOperations.js\";\n\n/** The `aco` schema setup step: the folder-level permissions table. */\nclass AcoSqlSchemaSetupImpl implements SqlSchemaSetup.Interface {\n public readonly name = \"aco\";\n\n public constructor(\n private readonly knex: KnexClient.Interface,\n private readonly schemaConfig?: SqlSchemaConfig.Interface\n ) {}\n\n public setup(): Promise<void> {\n const operations = new FolderLevelPermissionsStorageOperations({\n knex: this.knex.client,\n tableNamePrefix: this.schemaConfig?.tableNamePrefix\n });\n return operations.setupSchema();\n }\n}\n\nexport const AcoSqlSchemaSetup = SqlSchemaSetup.createImplementation({\n implementation: AcoSqlSchemaSetupImpl,\n dependencies: [KnexClient, [SqlSchemaConfig, { optional: true }]]\n});\n"],"names":["AcoSqlSchemaSetupImpl","knex","schemaConfig","operations","FolderLevelPermissionsStorageOperations","AcoSqlSchemaSetup","SqlSchemaSetup","KnexClient","SqlSchemaConfig"],"mappings":";;AAIA,MAAMA;IAGF,YACqBC,IAA0B,EAC1BC,YAAwC,CAC3D;aAFmBD,IAAI,GAAJA;aACAC,YAAY,GAAZA;aAJL,IAAI,GAAG;IAKpB;IAEI,QAAuB;QAC1B,MAAMC,aAAa,IAAIC,wCAAwC;YAC3D,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;YACtB,iBAAiB,IAAI,CAAC,YAAY,EAAE;QACxC;QACA,OAAOD,WAAW,WAAW;IACjC;AACJ;AAEO,MAAME,oBAAoBC,eAAe,oBAAoB,CAAC;IACjE,gBAAgBN;IAChB,cAAc;QAACO;QAAY;YAACC;YAAiB;gBAAE,UAAU;YAAK;SAAE;KAAC;AACrE"}
@@ -3,11 +3,17 @@ import type { AcoFolderLevelPermissionsStorageOperations, FolderLevelPermission,
3
3
  export interface StorageOperationsConfig {
4
4
  knex: Knex;
5
5
  tableNamePrefix?: string;
6
+ /**
7
+ * The schema was set up before the API took traffic (see `SqlSchemaConfig` in
8
+ * `@webiny/api-core-sql`): the table is never checked for or created at runtime.
9
+ */
10
+ schemaManaged?: boolean;
6
11
  }
7
12
  export declare class FolderLevelPermissionsStorageOperations implements AcoFolderLevelPermissionsStorageOperations {
8
13
  private readonly knex;
9
14
  private readonly tableName;
10
- constructor({ knex, tableNamePrefix }: StorageOperationsConfig);
15
+ private readonly schemaManaged;
16
+ constructor({ knex, tableNamePrefix, schemaManaged }: StorageOperationsConfig);
11
17
  list({ where: { tenant, type, path_startsWith, parentId } }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]>;
12
18
  get({ tenant, id }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null>;
13
19
  create({ data }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission>;
@@ -1,8 +1,9 @@
1
1
  import { WebinyError } from "@webiny/error";
2
2
  const BASE_TABLE_NAME = "webiny_aco_flp";
3
3
  class FolderLevelPermissionsStorageOperations {
4
- constructor({ knex, tableNamePrefix }){
4
+ constructor({ knex, tableNamePrefix, schemaManaged }){
5
5
  this.knex = knex;
6
+ this.schemaManaged = true === schemaManaged;
6
7
  this.tableName = tableNamePrefix ? `${tableNamePrefix}_${BASE_TABLE_NAME}` : BASE_TABLE_NAME;
7
8
  }
8
9
  async list({ where: { tenant, type, path_startsWith, parentId } }) {
@@ -121,7 +122,7 @@ class FolderLevelPermissionsStorageOperations {
121
122
  }
122
123
  }
123
124
  async ensureTable() {
124
- if ("true" === process.env.WEBINY_SQL_SCHEMA_MANAGED) return;
125
+ if (this.schemaManaged) return;
125
126
  await this.setupSchema();
126
127
  }
127
128
  async setupSchema() {
@@ -1 +1 @@
1
- {"version":3,"file":"FolderLevelPermissionsStorageOperations.js","sources":["../src/FolderLevelPermissionsStorageOperations.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n AcoFolderLevelPermissionsStorageOperations,\n FolderLevelPermission,\n StorageOperationsBatchUpdateFlpParams,\n StorageOperationsCreateFlpParams,\n StorageOperationsDeleteFlpParams,\n StorageOperationsGetFlpParams,\n StorageOperationsListFlpsParams,\n StorageOperationsUpdateFlpParams\n} from \"@webiny/api-aco/types.js\";\n\ninterface FlpRow {\n id: string;\n tenant: string;\n type: string;\n slug: string;\n path: string;\n parentId: string;\n permissions: string;\n}\n\nconst BASE_TABLE_NAME = \"webiny_aco_flp\";\n\nexport interface StorageOperationsConfig {\n knex: Knex;\n tableNamePrefix?: string;\n}\n\nexport class FolderLevelPermissionsStorageOperations implements AcoFolderLevelPermissionsStorageOperations {\n private readonly knex: Knex;\n private readonly tableName: string;\n\n constructor({ knex, tableNamePrefix }: StorageOperationsConfig) {\n this.knex = knex;\n this.tableName = tableNamePrefix\n ? `${tableNamePrefix}_${BASE_TABLE_NAME}`\n : BASE_TABLE_NAME;\n }\n\n public async list({\n where: { tenant, type, path_startsWith, parentId }\n }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]> {\n try {\n await this.ensureTable();\n\n if (parentId) {\n const rows = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"parentId\", parentId);\n\n return rows.map(row => this.fromRow(row));\n }\n\n if (path_startsWith) {\n const rows = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"type\", type)\n .andWhere(\"path\", \"like\", path_startsWith + \"%\");\n\n return rows.map(row => this.fromRow(row));\n }\n\n throw new WebinyError(\"Missing required parameters.\", \"LIST_FLP_MISSING_PARAMETERS\", {\n tenant,\n type,\n path_startsWith,\n parentId\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list folder level permissions.\",\n code: \"LIST_FLP_ERROR\"\n });\n }\n }\n\n public async get({\n tenant,\n id\n }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null> {\n try {\n await this.ensureTable();\n\n const row = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"id\", id)\n .first();\n\n if (!row) {\n return null;\n }\n\n return this.fromRow(row);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not load folder level permission.\",\n code: \"GET_FLP_ERROR\",\n data: { tenant, id }\n });\n }\n }\n\n public async create({\n data\n }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission> {\n try {\n await this.ensureTable();\n\n await this.knex<FlpRow>(this.tableName).insert(this.toRow(data));\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not create folder level permission.\",\n code: \"CREATE_FLP_ERROR\",\n data: { data }\n });\n }\n }\n\n public async update({\n data: inputData,\n original\n }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission> {\n try {\n await this.ensureTable();\n\n const data = {\n ...original,\n ...inputData\n };\n\n await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", data.tenant)\n .andWhere(\"id\", data.id)\n .update(this.toRow(data));\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update folder level permission.\",\n code: \"UPDATE_FLP_ERROR\",\n data: { inputData, original }\n });\n }\n }\n\n public async delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void> {\n try {\n await this.ensureTable();\n\n await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", flp.tenant)\n .andWhere(\"id\", flp.id)\n .delete();\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete folder level permission.\",\n code: \"DELETE_FLP_ERROR\",\n data: { flp }\n });\n }\n }\n\n public async batchUpdate({\n items\n }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]> {\n try {\n await this.ensureTable();\n\n // Built inside the callback: a transaction that loses its connection runs it again.\n return await this.knex.transaction(async trx => {\n const updatedItems: FolderLevelPermission[] = [];\n for (const { original, data: inputData } of items) {\n const data = {\n ...original,\n ...inputData\n };\n\n await trx<FlpRow>(this.tableName)\n .where(\"tenant\", data.tenant)\n .andWhere(\"id\", data.id)\n .update(this.toRow(data));\n\n updatedItems.push(data);\n }\n return updatedItems;\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not batch update folder level permissions.\",\n code: \"BATCH_UPDATE_FLP_ERROR\",\n data: { items }\n });\n }\n }\n\n private async ensureTable(): Promise<void> {\n // Same switch as `isSqlSchemaManaged()` in @webiny/api-core-sql: the table was created at\n // deploy time, so don't check for it on every call.\n if (process.env.WEBINY_SQL_SCHEMA_MANAGED === \"true\") {\n return;\n }\n await this.setupSchema();\n }\n\n /* Creates the table if missing, whatever the mode (deploy-time schema setup). */\n public async setupSchema(): Promise<void> {\n const exists = await this.knex.schema.hasTable(this.tableName);\n if (exists) {\n return;\n }\n\n await this.knex.schema.createTable(this.tableName, table => {\n table.text(\"id\").notNullable();\n table.text(\"tenant\").notNullable();\n table.text(\"type\").notNullable();\n table.text(\"slug\").notNullable();\n table.text(\"path\").notNullable();\n table.text(\"parentId\").notNullable();\n table.text(\"permissions\").notNullable();\n table.primary([\"tenant\", \"id\"]);\n });\n }\n\n private toRow(data: FolderLevelPermission & { tenant: string }): FlpRow {\n return {\n id: data.id,\n tenant: data.tenant,\n type: data.type,\n slug: data.slug,\n path: data.path,\n parentId: data.parentId,\n permissions: JSON.stringify(data.permissions)\n };\n }\n\n private fromRow(row: FlpRow): FolderLevelPermission {\n return {\n id: row.id,\n parentId: row.parentId,\n slug: row.slug,\n path: row.path,\n permissions: JSON.parse(row.permissions),\n type: row.type\n };\n }\n}\n"],"names":["BASE_TABLE_NAME","FolderLevelPermissionsStorageOperations","knex","tableNamePrefix","tenant","type","path_startsWith","parentId","rows","row","WebinyError","err","id","data","inputData","original","flp","items","trx","updatedItems","process","exists","table","JSON"],"mappings":";AAuBA,MAAMA,kBAAkB;AAOjB,MAAMC;IAIT,YAAY,EAAEC,IAAI,EAAEC,eAAe,EAA2B,CAAE;QAC5D,IAAI,CAAC,IAAI,GAAGD;QACZ,IAAI,CAAC,SA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AAQ,WAAW;YAC9BA,MAAM,IAAI,CAAC,YAAY,WAAW;YAClCA,MAAM,IAAI,CAAC,eAAe,WAAW;YACrCA,MAAM,OAAO,CAAC;gBAAC;gBAAU;aAAK;QAClC;IACJ;IAEQ,MAAMT,IAAgD,EAAU;QACpE,OAAO;YACH,IAAIA,KAAK,EAAE;YACX,QAAQA,KAAK,MAAM;YACnB,MAAMA,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,UAAUA,KAAK,QAAQ;YACvB,aAAaU,KAAK,SAAS,CAACV,KAAK,WAAW;QAChD;IACJ;IAEQ,QAAQJ,GAAW,EAAyB;QAChD,OAAO;YACH,IAAIA,IAAI,EAAE;YACV,UAAUA,IAAI,QAAQ;YACtB,MAAMA,IAAI,IAAI;YACd,MAAMA,IAAI,IAAI;YACd,aAAac,KAAK,KAAK,CAACd,IAAI,WAAW;YACvC,MAAMA,IAAI,IAAI;QAClB;IACJ;AACJ"}
1
+ {"version":3,"file":"FolderLevelPermissionsStorageOperations.js","sources":["../src/FolderLevelPermissionsStorageOperations.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n AcoFolderLevelPermissionsStorageOperations,\n FolderLevelPermission,\n StorageOperationsBatchUpdateFlpParams,\n StorageOperationsCreateFlpParams,\n StorageOperationsDeleteFlpParams,\n StorageOperationsGetFlpParams,\n StorageOperationsListFlpsParams,\n StorageOperationsUpdateFlpParams\n} from \"@webiny/api-aco/types.js\";\n\ninterface FlpRow {\n id: string;\n tenant: string;\n type: string;\n slug: string;\n path: string;\n parentId: string;\n permissions: string;\n}\n\nconst BASE_TABLE_NAME = \"webiny_aco_flp\";\n\nexport interface StorageOperationsConfig {\n knex: Knex;\n tableNamePrefix?: string;\n /**\n * The schema was set up before the API took traffic (see `SqlSchemaConfig` in\n * `@webiny/api-core-sql`): the table is never checked for or created at runtime.\n */\n schemaManaged?: boolean;\n}\n\nexport class FolderLevelPermissionsStorageOperations implements AcoFolderLevelPermissionsStorageOperations {\n private readonly knex: Knex;\n private readonly tableName: string;\n private readonly schemaManaged: boolean;\n\n constructor({ knex, tableNamePrefix, schemaManaged }: StorageOperationsConfig) {\n this.knex = knex;\n this.schemaManaged = schemaManaged === true;\n this.tableName = tableNamePrefix\n ? `${tableNamePrefix}_${BASE_TABLE_NAME}`\n : BASE_TABLE_NAME;\n }\n\n public async list({\n where: { tenant, type, path_startsWith, parentId }\n }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]> {\n try {\n await this.ensureTable();\n\n if (parentId) {\n const rows = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"parentId\", parentId);\n\n return rows.map(row => this.fromRow(row));\n }\n\n if (path_startsWith) {\n const rows = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"type\", type)\n .andWhere(\"path\", \"like\", path_startsWith + \"%\");\n\n return rows.map(row => this.fromRow(row));\n }\n\n throw new WebinyError(\"Missing required parameters.\", \"LIST_FLP_MISSING_PARAMETERS\", {\n tenant,\n type,\n path_startsWith,\n parentId\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list folder level permissions.\",\n code: \"LIST_FLP_ERROR\"\n });\n }\n }\n\n public async get({\n tenant,\n id\n }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null> {\n try {\n await this.ensureTable();\n\n const row = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"id\", id)\n .first();\n\n if (!row) {\n return null;\n }\n\n return this.fromRow(row);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not load folder level permission.\",\n code: \"GET_FLP_ERROR\",\n data: { tenant, id }\n });\n }\n }\n\n public async create({\n data\n }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission> {\n try {\n await this.ensureTable();\n\n await this.knex<FlpRow>(this.tableName).insert(this.toRow(data));\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not create folder level permission.\",\n code: \"CREATE_FLP_ERROR\",\n data: { data }\n });\n }\n }\n\n public async update({\n data: inputData,\n original\n }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission> {\n try {\n await this.ensureTable();\n\n const data = {\n ...original,\n ...inputData\n };\n\n await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", data.tenant)\n .andWhere(\"id\", data.id)\n .update(this.toRow(data));\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update folder level permission.\",\n code: \"UPDATE_FLP_ERROR\",\n data: { inputData, original }\n });\n }\n }\n\n public async delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void> {\n try {\n await this.ensureTable();\n\n await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", flp.tenant)\n .andWhere(\"id\", flp.id)\n .delete();\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete folder level permission.\",\n code: \"DELETE_FLP_ERROR\",\n data: { flp }\n });\n }\n }\n\n public async batchUpdate({\n items\n }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]> {\n try {\n await this.ensureTable();\n\n // Built inside the callback: a transaction that loses its connection runs it again.\n return await this.knex.transaction(async trx => {\n const updatedItems: FolderLevelPermission[] = [];\n for (const { original, data: inputData } of items) {\n const data = {\n ...original,\n ...inputData\n };\n\n await trx<FlpRow>(this.tableName)\n .where(\"tenant\", data.tenant)\n .andWhere(\"id\", data.id)\n .update(this.toRow(data));\n\n updatedItems.push(data);\n }\n return updatedItems;\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not batch update folder level permissions.\",\n code: \"BATCH_UPDATE_FLP_ERROR\",\n data: { items }\n });\n }\n }\n\n private async ensureTable(): Promise<void> {\n // Set up before the API took traffic, so don't check for it on every call.\n if (this.schemaManaged) {\n return;\n }\n await this.setupSchema();\n }\n\n /* Creates the table if missing, whatever the mode (deploy-time schema setup). */\n public async setupSchema(): Promise<void> {\n const exists = await this.knex.schema.hasTable(this.tableName);\n if (exists) {\n return;\n }\n\n await this.knex.schema.createTable(this.tableName, table => {\n table.text(\"id\").notNullable();\n table.text(\"tenant\").notNullable();\n table.text(\"type\").notNullable();\n table.text(\"slug\").notNullable();\n table.text(\"path\").notNullable();\n table.text(\"parentId\").notNullable();\n table.text(\"permissions\").notNullable();\n table.primary([\"tenant\", \"id\"]);\n });\n }\n\n private toRow(data: FolderLevelPermission & { tenant: string }): FlpRow {\n return {\n id: data.id,\n tenant: data.tenant,\n type: data.type,\n slug: data.slug,\n path: data.path,\n parentId: data.parentId,\n permissions: JSON.stringify(data.permissions)\n };\n }\n\n private fromRow(row: FlpRow): FolderLevelPermission {\n return {\n id: row.id,\n parentId: row.parentId,\n slug: row.slug,\n path: row.path,\n permissions: JSON.parse(row.permissions),\n type: row.type\n };\n }\n}\n"],"names":["BASE_TABLE_NAME","FolderLevelPermissionsStorageOperations","knex","tableNamePrefix","schemaManaged","tenant","type","path_startsWith","parentId","rows","row","WebinyError","err","id","data","inputData","original","flp","items","trx","updatedItems","exists","table","JSON"],"mappings":";AAuBA,MAAMA,kBAAkB;AAYjB,MAAMC;IAKT,YAAY,EAAEC,IAAI,EAAEC,eAAe,EAAEC,aAAa,EAA2B,CAAE;QAC3E,IAAI,CAAC,IAAI,GAAGF;QACZ,IAAI,CAAC,aAAa,GAAGE,AAAkB,SAAlBA;QACrB,IAAI,CAAC,SAAS,GAAGD,kBACX,GAAGA,gBAAgB,CAAC,EAAEH,iBAAiB,GACvCA;IACV;IAEA,MAAa,KAAK,EACd,OAAO,EAAEK,MAAM,EAAEC,IAAI,EAAEC,eAAe,EAAEC,QAAQ,EAAE,EACpB,EAAoC;QAClE,IAAI;YACA,MAAM,IAAI,CAAC,WAAW;YAEtB,IAAIA,UAAU;gBACV,MAAMC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAS,IAAI,CAAC,SAAS,EAC9C,KAAK,CAAC,UAAUJ,QAChB,QAAQ,CAAC,YAAYG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AChD;IACJ;IAEQ,QAAQJ,GAAW,EAAyB;QAChD,OAAO;YACH,IAAIA,IAAI,EAAE;YACV,UAAUA,IAAI,QAAQ;YACtB,MAAMA,IAAI,IAAI;YACd,MAAMA,IAAI,IAAI;YACd,aAAaa,KAAK,KAAK,CAACb,IAAI,WAAW;YACvC,MAAMA,IAAI,IAAI;QAClB;IACJ;AACJ"}
@@ -0,0 +1,11 @@
1
+ import { KnexClient, SqlSchemaConfig } from "@webiny/api-core-sql";
2
+ import { FlpStorageOperations } from "@webiny/api-aco/features/folder/shared/abstractions.js";
3
+ import { FolderLevelPermissionsStorageOperations } from "./FolderLevelPermissionsStorageOperations.js";
4
+ /** Folder-level permissions on the container's connection and table prefix. */
5
+ declare class SqlFlpStorageOperationsImpl extends FolderLevelPermissionsStorageOperations implements FlpStorageOperations.Interface {
6
+ constructor(knex: KnexClient.Interface, schemaConfig?: SqlSchemaConfig.Interface);
7
+ }
8
+ export declare const SqlFlpStorageOperations: typeof SqlFlpStorageOperationsImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-aco/types.js").AcoFolderLevelPermissionsStorageOperations>;
10
+ };
11
+ export {};
@@ -0,0 +1,27 @@
1
+ import { KnexClient, SqlSchemaConfig } from "@webiny/api-core-sql";
2
+ import { FlpStorageOperations } from "@webiny/api-aco/features/folder/shared/abstractions.js";
3
+ import { FolderLevelPermissionsStorageOperations } from "./FolderLevelPermissionsStorageOperations.js";
4
+ class SqlFlpStorageOperationsImpl extends FolderLevelPermissionsStorageOperations {
5
+ constructor(knex, schemaConfig){
6
+ super({
7
+ knex: knex.client,
8
+ tableNamePrefix: schemaConfig?.tableNamePrefix,
9
+ schemaManaged: schemaConfig?.isManaged() === true
10
+ });
11
+ }
12
+ }
13
+ const SqlFlpStorageOperations = FlpStorageOperations.createImplementation({
14
+ implementation: SqlFlpStorageOperationsImpl,
15
+ dependencies: [
16
+ KnexClient,
17
+ [
18
+ SqlSchemaConfig,
19
+ {
20
+ optional: true
21
+ }
22
+ ]
23
+ ]
24
+ });
25
+ export { SqlFlpStorageOperations };
26
+
27
+ //# sourceMappingURL=SqlFlpStorageOperations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SqlFlpStorageOperations.js","sources":["../src/SqlFlpStorageOperations.ts"],"sourcesContent":["import { KnexClient, SqlSchemaConfig } from \"@webiny/api-core-sql\";\nimport { FlpStorageOperations } from \"@webiny/api-aco/features/folder/shared/abstractions.js\";\nimport { FolderLevelPermissionsStorageOperations } from \"./FolderLevelPermissionsStorageOperations.js\";\n\n/** Folder-level permissions on the container's connection and table prefix. */\nclass SqlFlpStorageOperationsImpl\n extends FolderLevelPermissionsStorageOperations\n implements FlpStorageOperations.Interface\n{\n public constructor(knex: KnexClient.Interface, schemaConfig?: SqlSchemaConfig.Interface) {\n super({\n knex: knex.client,\n tableNamePrefix: schemaConfig?.tableNamePrefix,\n schemaManaged: schemaConfig?.isManaged() === true\n });\n }\n}\n\nexport const SqlFlpStorageOperations = FlpStorageOperations.createImplementation({\n implementation: SqlFlpStorageOperationsImpl,\n dependencies: [KnexClient, [SqlSchemaConfig, { optional: true }]]\n});\n"],"names":["SqlFlpStorageOperationsImpl","FolderLevelPermissionsStorageOperations","knex","schemaConfig","SqlFlpStorageOperations","FlpStorageOperations","KnexClient","SqlSchemaConfig"],"mappings":";;;AAKA,MAAMA,oCACMC;IAGR,YAAmBC,IAA0B,EAAEC,YAAwC,CAAE;QACrF,KAAK,CAAC;YACF,MAAMD,KAAK,MAAM;YACjB,iBAAiBC,cAAc;YAC/B,eAAeA,cAAc,gBAAgB;QACjD;IACJ;AACJ;AAEO,MAAMC,0BAA0BC,qBAAqB,oBAAoB,CAAC;IAC7E,gBAAgBL;IAChB,cAAc;QAACM;QAAY;YAACC;YAAiB;gBAAE,UAAU;YAAK;SAAE;KAAC;AACrE"}
package/feature.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ACO folder-level permissions on SQL, and the `aco` schema setup step. Registered per request, it
3
+ * runs on the connection (`KnexClient`) and the table settings (`SqlSchemaConfig`) the SQL storage
4
+ * keeps in the root. Folder-level permissions on this storage use the task-maintained FLP catalog.
5
+ */
6
+ export declare const AcoSqlFeature: {
7
+ name: string;
8
+ register(container: import("@webiny/di").Container): void;
9
+ };
10
+ /** `AcoSqlFeature` as an extension plugin, for setups that register storages that way. */
11
+ export declare const registerAcoSqlStorageOperations: () => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
package/feature.js ADDED
@@ -0,0 +1,19 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
3
+ import { TaskCatalogFlpFeature } from "@webiny/api-aco/flpTaskCatalog/index.js";
4
+ import { SqlFlpStorageOperations } from "./SqlFlpStorageOperations.js";
5
+ import { AcoSqlSchemaSetup } from "./AcoSqlSchemaSetup.js";
6
+ const AcoSqlFeature = createFeature({
7
+ name: "AcoSql",
8
+ register (container) {
9
+ container.register(SqlFlpStorageOperations);
10
+ container.register(AcoSqlSchemaSetup);
11
+ TaskCatalogFlpFeature.register(container);
12
+ }
13
+ });
14
+ const registerAcoSqlStorageOperations = ()=>createRegisterExtensionPlugin((context)=>{
15
+ AcoSqlFeature.register(context.container);
16
+ });
17
+ export { AcoSqlFeature, registerAcoSqlStorageOperations };
18
+
19
+ //# sourceMappingURL=feature.js.map
package/feature.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.js","sources":["../src/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { TaskCatalogFlpFeature } from \"@webiny/api-aco/flpTaskCatalog/index.js\";\nimport { SqlFlpStorageOperations } from \"./SqlFlpStorageOperations.js\";\nimport { AcoSqlSchemaSetup } from \"./AcoSqlSchemaSetup.js\";\n\n/**\n * ACO folder-level permissions on SQL, and the `aco` schema setup step. Registered per request, it\n * runs on the connection (`KnexClient`) and the table settings (`SqlSchemaConfig`) the SQL storage\n * keeps in the root. Folder-level permissions on this storage use the task-maintained FLP catalog.\n */\nexport const AcoSqlFeature = createFeature({\n name: \"AcoSql\",\n register(container) {\n container.register(SqlFlpStorageOperations);\n container.register(AcoSqlSchemaSetup);\n TaskCatalogFlpFeature.register(container);\n }\n});\n\n/** `AcoSqlFeature` as an extension plugin, for setups that register storages that way. */\nexport const registerAcoSqlStorageOperations = () => {\n return createRegisterExtensionPlugin(context => {\n AcoSqlFeature.register(context.container);\n });\n};\n"],"names":["AcoSqlFeature","createFeature","container","SqlFlpStorageOperations","AcoSqlSchemaSetup","TaskCatalogFlpFeature","registerAcoSqlStorageOperations","createRegisterExtensionPlugin","context"],"mappings":";;;;;AAWO,MAAMA,gBAAgBC,cAAc;IACvC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBC,sBAAsB,QAAQ,CAACH;IACnC;AACJ;AAGO,MAAMI,kCAAkC,IACpCC,8BAA8BC,CAAAA;QACjCR,cAAc,QAAQ,CAACQ,QAAQ,SAAS;IAC5C"}
package/index.d.ts CHANGED
@@ -1,7 +1 @@
1
- import type { Knex } from "knex";
2
- interface RegisterAcoSqlStorageOperationsParams {
3
- knex: Knex;
4
- tableNamePrefix?: string;
5
- }
6
- export declare const registerAcoSqlStorageOperations: (params: RegisterAcoSqlStorageOperationsParams) => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
7
- export {};
1
+ export { AcoSqlFeature, registerAcoSqlStorageOperations } from "./feature.js";
package/index.js CHANGED
@@ -1,15 +1 @@
1
- import { createRegisterExtensionPlugin } from "@webiny/handler";
2
- import { FolderLevelPermissionsStorageOperations } from "./FolderLevelPermissionsStorageOperations.js";
3
- import { FlpStorageOperations } from "@webiny/api-aco/features/folder/shared/abstractions.js";
4
- import { TaskCatalogFlpFeature } from "@webiny/api-aco/flpTaskCatalog/index.js";
5
- const registerAcoSqlStorageOperations = (params)=>createRegisterExtensionPlugin((context)=>{
6
- const flpStorageOperations = new FolderLevelPermissionsStorageOperations({
7
- knex: params.knex,
8
- tableNamePrefix: params.tableNamePrefix
9
- });
10
- context.container.registerInstance(FlpStorageOperations, flpStorageOperations);
11
- TaskCatalogFlpFeature.register(context.container);
12
- });
13
- export { registerAcoSqlStorageOperations };
14
-
15
- //# sourceMappingURL=index.js.map
1
+ export { AcoSqlFeature, registerAcoSqlStorageOperations } from "./feature.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-aco-sql",
3
- "version": "6.6.0-alpha.10",
3
+ "version": "6.6.0-alpha.12",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "@webiny/api-aco",
@@ -20,14 +20,16 @@
20
20
  "./*": "./*"
21
21
  },
22
22
  "dependencies": {
23
- "@webiny/api-aco": "6.6.0-alpha.10",
24
- "@webiny/error": "6.6.0-alpha.10",
25
- "@webiny/handler": "6.6.0-alpha.10",
23
+ "@webiny/api-aco": "6.6.0-alpha.12",
24
+ "@webiny/api-core-sql": "6.6.0-alpha.12",
25
+ "@webiny/error": "6.6.0-alpha.12",
26
+ "@webiny/feature": "6.6.0-alpha.12",
27
+ "@webiny/handler": "6.6.0-alpha.12",
26
28
  "knex": "3.3.0"
27
29
  },
28
30
  "devDependencies": {
29
- "@webiny/api-core": "6.6.0-alpha.10",
30
- "@webiny/build-tools": "6.6.0-alpha.10",
31
+ "@webiny/api-core": "6.6.0-alpha.12",
32
+ "@webiny/build-tools": "6.6.0-alpha.12",
31
33
  "better-sqlite3": "13.0.3",
32
34
  "rimraf": "6.1.3",
33
35
  "typescript": "7.0.2",
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { FolderLevelPermissionsStorageOperations } from \"./FolderLevelPermissionsStorageOperations.js\";\nimport { FlpStorageOperations } from \"@webiny/api-aco/features/folder/shared/abstractions.js\";\nimport { TaskCatalogFlpFeature } from \"@webiny/api-aco/flpTaskCatalog/index.js\";\n\ninterface RegisterAcoSqlStorageOperationsParams {\n knex: Knex;\n tableNamePrefix?: string;\n}\n\nexport const registerAcoSqlStorageOperations = (params: RegisterAcoSqlStorageOperationsParams) => {\n return createRegisterExtensionPlugin(context => {\n const flpStorageOperations = new FolderLevelPermissionsStorageOperations({\n knex: params.knex,\n tableNamePrefix: params.tableNamePrefix\n });\n\n context.container.registerInstance(FlpStorageOperations, flpStorageOperations);\n // Folder-level permissions on this storage use the task-maintained FLP catalog.\n TaskCatalogFlpFeature.register(context.container);\n });\n};\n"],"names":["registerAcoSqlStorageOperations","params","createRegisterExtensionPlugin","context","flpStorageOperations","FolderLevelPermissionsStorageOperations","FlpStorageOperations","TaskCatalogFlpFeature"],"mappings":";;;;AAWO,MAAMA,kCAAkC,CAACC,SACrCC,8BAA8BC,CAAAA;QACjC,MAAMC,uBAAuB,IAAIC,wCAAwC;YACrE,MAAMJ,OAAO,IAAI;YACjB,iBAAiBA,OAAO,eAAe;QAC3C;QAEAE,QAAQ,SAAS,CAAC,gBAAgB,CAACG,sBAAsBF;QAEzDG,sBAAsB,QAAQ,CAACJ,QAAQ,SAAS;IACpD"}