@webiny/api-aco 0.0.0-unstable.8feaff8c32 → 0.0.0-unstable.98511f29f1

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.
@@ -35,26 +35,25 @@ const onFolderBeforeDeleteHook = ({
35
35
  if (children.length > 0) {
36
36
  throwDeleteError(folder);
37
37
  }
38
- /**
39
- * Then for entries in each of the apps.
40
- * Because we split the apps we must do it like this.
41
- */
42
- const apps = aco.listApps();
43
- for (const app of apps) {
44
- const [records] = await app.search.list({
45
- where: {
46
- type,
47
- location: {
48
- folderId: id
49
- }
50
- },
51
- limit: 1
52
- });
53
- if (records.length === 0) {
54
- continue;
55
- }
56
- throwDeleteError(folder);
38
+ let app = undefined;
39
+ try {
40
+ app = aco.getApp(type);
41
+ } catch {
42
+ return;
43
+ }
44
+ const [records] = await app.search.list({
45
+ where: {
46
+ type,
47
+ location: {
48
+ folderId: id
49
+ }
50
+ },
51
+ limit: 1
52
+ });
53
+ if (records.length === 0) {
54
+ return;
57
55
  }
56
+ throwDeleteError(folder);
58
57
  } catch (error) {
59
58
  throw _error.default.from(error, {
60
59
  message: "Error while executing onFolderBeforeDelete hook",
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","throwDeleteError","folder","WebinyError","onFolderBeforeDeleteHook","aco","onFolderBeforeDelete","subscribe","id","type","children","list","where","parentId","limit","length","apps","listApps","app","records","search","location","folderId","error","from","message","code","exports"],"sources":["onFolderBeforeDelete.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AcoContext, Folder } from \"~/types\";\n\nconst throwDeleteError = (folder: Folder) => {\n throw new WebinyError(\n \"Error: delete all child folders and entries before proceeding.\",\n \"DELETE_FOLDER_WITH_CHILDREN\",\n {\n folder\n }\n );\n};\n\nexport const onFolderBeforeDeleteHook = ({ aco }: AcoContext) => {\n aco.folder.onFolderBeforeDelete.subscribe(async ({ folder }) => {\n try {\n const { id, type } = folder;\n /**\n * First we check for the child folders.\n */\n const [children] = await aco.folder.list({\n where: {\n type,\n parentId: id\n },\n limit: 1\n });\n if (children.length > 0) {\n throwDeleteError(folder);\n }\n /**\n * Then for entries in each of the apps.\n * Because we split the apps we must do it like this.\n */\n const apps = aco.listApps();\n for (const app of apps) {\n const [records] = await app.search.list({\n where: {\n type,\n location: {\n folderId: id\n }\n },\n limit: 1\n });\n if (records.length === 0) {\n continue;\n }\n throwDeleteError(folder);\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFolderBeforeDelete hook\",\n code: \"ACO_BEFORE_FOLDER_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,MAAMC,gBAAgB,GAAIC,MAAc,IAAK;EACzC,MAAM,IAAIC,cAAW,CACjB,gEAAgE,EAChE,6BAA6B,EAC7B;IACID;EACJ,CACJ,CAAC;AACL,CAAC;AAEM,MAAME,wBAAwB,GAAGA,CAAC;EAAEC;AAAgB,CAAC,KAAK;EAC7DA,GAAG,CAACH,MAAM,CAACI,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEL;EAAO,CAAC,KAAK;IAC5D,IAAI;MACA,MAAM;QAAEM,EAAE;QAAEC;MAAK,CAAC,GAAGP,MAAM;MAC3B;AACZ;AACA;MACY,MAAM,CAACQ,QAAQ,CAAC,GAAG,MAAML,GAAG,CAACH,MAAM,CAACS,IAAI,CAAC;QACrCC,KAAK,EAAE;UACHH,IAAI;UACJI,QAAQ,EAAEL;QACd,CAAC;QACDM,KAAK,EAAE;MACX,CAAC,CAAC;MACF,IAAIJ,QAAQ,CAACK,MAAM,GAAG,CAAC,EAAE;QACrBd,gBAAgB,CAACC,MAAM,CAAC;MAC5B;MACA;AACZ;AACA;AACA;MACY,MAAMc,IAAI,GAAGX,GAAG,CAACY,QAAQ,CAAC,CAAC;MAC3B,KAAK,MAAMC,GAAG,IAAIF,IAAI,EAAE;QACpB,MAAM,CAACG,OAAO,CAAC,GAAG,MAAMD,GAAG,CAACE,MAAM,CAACT,IAAI,CAAC;UACpCC,KAAK,EAAE;YACHH,IAAI;YACJY,QAAQ,EAAE;cACNC,QAAQ,EAAEd;YACd;UACJ,CAAC;UACDM,KAAK,EAAE;QACX,CAAC,CAAC;QACF,IAAIK,OAAO,CAACJ,MAAM,KAAK,CAAC,EAAE;UACtB;QACJ;QACAd,gBAAgB,CAACC,MAAM,CAAC;MAC5B;IACJ,CAAC,CAAC,OAAOqB,KAAK,EAAE;MACZ,MAAMpB,cAAW,CAACqB,IAAI,CAACD,KAAK,EAAE;QAC1BE,OAAO,EAAE,iDAAiD;QAC1DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAvB,wBAAA,GAAAA,wBAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","throwDeleteError","folder","WebinyError","onFolderBeforeDeleteHook","aco","onFolderBeforeDelete","subscribe","id","type","children","list","where","parentId","limit","length","app","undefined","getApp","records","search","location","folderId","error","from","message","code","exports"],"sources":["onFolderBeforeDelete.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AcoContext, Folder, IAcoApp } from \"~/types\";\n\nconst throwDeleteError = (folder: Folder) => {\n throw new WebinyError(\n \"Error: delete all child folders and entries before proceeding.\",\n \"DELETE_FOLDER_WITH_CHILDREN\",\n {\n folder\n }\n );\n};\n\nexport const onFolderBeforeDeleteHook = ({ aco }: AcoContext) => {\n aco.folder.onFolderBeforeDelete.subscribe(async ({ folder }) => {\n try {\n const { id, type } = folder;\n /**\n * First we check for the child folders.\n */\n const [children] = await aco.folder.list({\n where: {\n type,\n parentId: id\n },\n limit: 1\n });\n if (children.length > 0) {\n throwDeleteError(folder);\n }\n\n let app: IAcoApp | undefined = undefined;\n try {\n app = aco.getApp(type);\n } catch {\n return;\n }\n const [records] = await app.search.list({\n where: {\n type,\n location: {\n folderId: id\n }\n },\n limit: 1\n });\n if (records.length === 0) {\n return;\n }\n throwDeleteError(folder);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFolderBeforeDelete hook\",\n code: \"ACO_BEFORE_FOLDER_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,MAAMC,gBAAgB,GAAIC,MAAc,IAAK;EACzC,MAAM,IAAIC,cAAW,CACjB,gEAAgE,EAChE,6BAA6B,EAC7B;IACID;EACJ,CACJ,CAAC;AACL,CAAC;AAEM,MAAME,wBAAwB,GAAGA,CAAC;EAAEC;AAAgB,CAAC,KAAK;EAC7DA,GAAG,CAACH,MAAM,CAACI,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEL;EAAO,CAAC,KAAK;IAC5D,IAAI;MACA,MAAM;QAAEM,EAAE;QAAEC;MAAK,CAAC,GAAGP,MAAM;MAC3B;AACZ;AACA;MACY,MAAM,CAACQ,QAAQ,CAAC,GAAG,MAAML,GAAG,CAACH,MAAM,CAACS,IAAI,CAAC;QACrCC,KAAK,EAAE;UACHH,IAAI;UACJI,QAAQ,EAAEL;QACd,CAAC;QACDM,KAAK,EAAE;MACX,CAAC,CAAC;MACF,IAAIJ,QAAQ,CAACK,MAAM,GAAG,CAAC,EAAE;QACrBd,gBAAgB,CAACC,MAAM,CAAC;MAC5B;MAEA,IAAIc,GAAwB,GAAGC,SAAS;MACxC,IAAI;QACAD,GAAG,GAAGX,GAAG,CAACa,MAAM,CAACT,IAAI,CAAC;MAC1B,CAAC,CAAC,MAAM;QACJ;MACJ;MACA,MAAM,CAACU,OAAO,CAAC,GAAG,MAAMH,GAAG,CAACI,MAAM,CAACT,IAAI,CAAC;QACpCC,KAAK,EAAE;UACHH,IAAI;UACJY,QAAQ,EAAE;YACNC,QAAQ,EAAEd;UACd;QACJ,CAAC;QACDM,KAAK,EAAE;MACX,CAAC,CAAC;MACF,IAAIK,OAAO,CAACJ,MAAM,KAAK,CAAC,EAAE;QACtB;MACJ;MACAd,gBAAgB,CAACC,MAAM,CAAC;IAC5B,CAAC,CAAC,OAAOqB,KAAK,EAAE;MACZ,MAAMpB,cAAW,CAACqB,IAAI,CAACD,KAAK,EAAE;QAC1BE,OAAO,EAAE,iDAAiD;QAC1DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAvB,wBAAA,GAAAA,wBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-aco",
3
- "version": "0.0.0-unstable.8feaff8c32",
3
+ "version": "0.0.0-unstable.98511f29f1",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "aco:base"
@@ -23,16 +23,16 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@ungap/structured-clone": "1.2.0",
26
- "@webiny/api": "0.0.0-unstable.8feaff8c32",
27
- "@webiny/api-headless-cms": "0.0.0-unstable.8feaff8c32",
28
- "@webiny/api-i18n": "0.0.0-unstable.8feaff8c32",
29
- "@webiny/api-security": "0.0.0-unstable.8feaff8c32",
30
- "@webiny/api-tenancy": "0.0.0-unstable.8feaff8c32",
31
- "@webiny/error": "0.0.0-unstable.8feaff8c32",
32
- "@webiny/handler": "0.0.0-unstable.8feaff8c32",
33
- "@webiny/handler-graphql": "0.0.0-unstable.8feaff8c32",
34
- "@webiny/pubsub": "0.0.0-unstable.8feaff8c32",
35
- "@webiny/utils": "0.0.0-unstable.8feaff8c32",
26
+ "@webiny/api": "0.0.0-unstable.98511f29f1",
27
+ "@webiny/api-headless-cms": "0.0.0-unstable.98511f29f1",
28
+ "@webiny/api-i18n": "0.0.0-unstable.98511f29f1",
29
+ "@webiny/api-security": "0.0.0-unstable.98511f29f1",
30
+ "@webiny/api-tenancy": "0.0.0-unstable.98511f29f1",
31
+ "@webiny/error": "0.0.0-unstable.98511f29f1",
32
+ "@webiny/handler": "0.0.0-unstable.98511f29f1",
33
+ "@webiny/handler-graphql": "0.0.0-unstable.98511f29f1",
34
+ "@webiny/pubsub": "0.0.0-unstable.98511f29f1",
35
+ "@webiny/utils": "0.0.0-unstable.98511f29f1",
36
36
  "lodash": "4.17.21"
37
37
  },
38
38
  "devDependencies": {
@@ -42,19 +42,19 @@
42
42
  "@babel/preset-typescript": "7.22.5",
43
43
  "@babel/runtime": "7.22.6",
44
44
  "@types/ungap__structured-clone": "0.3.0",
45
- "@webiny/api-i18n-ddb": "0.0.0-unstable.8feaff8c32",
46
- "@webiny/api-security-so-ddb": "0.0.0-unstable.8feaff8c32",
47
- "@webiny/api-tenancy-so-ddb": "0.0.0-unstable.8feaff8c32",
48
- "@webiny/api-wcp": "0.0.0-unstable.8feaff8c32",
49
- "@webiny/cli": "0.0.0-unstable.8feaff8c32",
50
- "@webiny/handler-aws": "0.0.0-unstable.8feaff8c32",
51
- "@webiny/plugins": "0.0.0-unstable.8feaff8c32",
52
- "@webiny/project-utils": "0.0.0-unstable.8feaff8c32",
45
+ "@webiny/api-i18n-ddb": "0.0.0-unstable.98511f29f1",
46
+ "@webiny/api-security-so-ddb": "0.0.0-unstable.98511f29f1",
47
+ "@webiny/api-tenancy-so-ddb": "0.0.0-unstable.98511f29f1",
48
+ "@webiny/api-wcp": "0.0.0-unstable.98511f29f1",
49
+ "@webiny/cli": "0.0.0-unstable.98511f29f1",
50
+ "@webiny/handler-aws": "0.0.0-unstable.98511f29f1",
51
+ "@webiny/plugins": "0.0.0-unstable.98511f29f1",
52
+ "@webiny/project-utils": "0.0.0-unstable.98511f29f1",
53
53
  "graphql": "15.8.0",
54
54
  "prettier": "2.8.8",
55
55
  "rimraf": "3.0.2",
56
56
  "ttypescript": "1.5.15",
57
57
  "typescript": "4.7.4"
58
58
  },
59
- "gitHead": "8feaff8c32ad81701938e9e3eadd836c8eb2fcb1"
59
+ "gitHead": "98511f29f1e1fc7d03ed0d1379d0a0aeff6dae84"
60
60
  }