@friggframework/devtools 2.0.0--canary.744.9a69fb7.0 → 2.0.0--canary.744.e18e27f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,9 @@ class AdminScriptBuilder extends InfrastructureBuilder {
33
33
  appDefinition.reports.length > 0;
34
34
  const hasBuiltinReports =
35
35
  appDefinition.admin?.includeBuiltinReports === true;
36
- return hasScripts || hasReports || hasBuiltinReports;
36
+ const hasBuiltinScripts =
37
+ appDefinition.admin?.includeBuiltinScripts === true;
38
+ return hasScripts || hasReports || hasBuiltinReports || hasBuiltinScripts;
37
39
  }
38
40
 
39
41
  getDependencies() {
@@ -83,6 +85,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
83
85
  : [];
84
86
  const hasReports =
85
87
  reports.length > 0 || adminConfig.includeBuiltinReports === true;
88
+ // The built-in scripts (registered at runtime by the admin-scripts
89
+ // bootstrap) need the same queue, executor and routes as app scripts.
90
+ const hasScripts =
91
+ adminScripts.length > 0 || adminConfig.includeBuiltinScripts === true;
86
92
 
87
93
  // Only non-JSON report output is stored in S3, so provision the bucket
88
94
  // only for that. Built-in reports emit JSON, so they don't trigger it.
@@ -99,8 +105,13 @@ class AdminScriptBuilder extends InfrastructureBuilder {
99
105
  iamStatements: [],
100
106
  };
101
107
 
102
- if (adminScripts.length > 0) {
103
- console.log(` Processing ${adminScripts.length} scripts...`);
108
+ if (hasScripts) {
109
+ const builtinNote = adminConfig.includeBuiltinScripts
110
+ ? ' and the built-in scripts'
111
+ : '';
112
+ console.log(
113
+ ` Processing ${adminScripts.length} app scripts${builtinNote}...`
114
+ );
104
115
  this.createAdminScriptQueue(result, appDefinition);
105
116
  this.createScriptExecutorFunction(appDefinition, result, usePrismaLayer);
106
117
  this.createAdminScriptRoutes(appDefinition, result, usePrismaLayer);
@@ -127,12 +138,9 @@ class AdminScriptBuilder extends InfrastructureBuilder {
127
138
  }
128
139
  }
129
140
 
130
- if (
131
- adminConfig.enableScheduling &&
132
- (adminScripts.length > 0 || hasReports)
133
- ) {
141
+ if (adminConfig.enableScheduling && (hasScripts || hasReports)) {
134
142
  this.createSchedulerResources(appDefinition, result, {
135
- scriptsPresent: adminScripts.length > 0,
143
+ scriptsPresent: hasScripts,
136
144
  hasReports,
137
145
  });
138
146
  }
@@ -44,6 +44,12 @@ describe('AdminScriptBuilder', () => {
44
44
  expect(adminScriptBuilder.shouldExecute(appDefinition)).toBe(true);
45
45
  });
46
46
 
47
+ it('should return true when only the built-in scripts are enabled', () => {
48
+ expect(
49
+ adminScriptBuilder.shouldExecute({ admin: { includeBuiltinScripts: true } })
50
+ ).toBe(true);
51
+ });
52
+
47
53
  it('should return false when adminScripts is not an array', () => {
48
54
  const appDefinition = {
49
55
  adminScripts: { name: 'test' },
@@ -742,6 +748,27 @@ describe('AdminScriptBuilder', () => {
742
748
  expect(result.functions.reportExecutor).toBeDefined();
743
749
  });
744
750
 
751
+ it('creates the script queue, executor and routes when only the built-in scripts are enabled', async () => {
752
+ const result = await adminScriptBuilder.build(
753
+ { admin: { includeBuiltinScripts: true } },
754
+ {}
755
+ );
756
+
757
+ expect(result.resources.AdminScriptQueue).toBeDefined();
758
+ expect(result.functions.adminScriptExecutor).toBeDefined();
759
+ expect(result.functions.adminScriptRouter).toBeDefined();
760
+ });
761
+
762
+ it('provisions scheduling for the built-in scripts', async () => {
763
+ const result = await adminScriptBuilder.build(
764
+ { admin: { includeBuiltinScripts: true, enableScheduling: true } },
765
+ {}
766
+ );
767
+
768
+ expect(result.resources.AdminScriptQueue).toBeDefined();
769
+ expect(JSON.stringify(result.resources)).toMatch(/Schedule/);
770
+ });
771
+
745
772
  it('does NOT create ReportQueue or reportExecutor when only adminScripts are present', async () => {
746
773
  const appDefinition = {
747
774
  adminScripts: [{ Definition: { name: 'test-script' } }],
@@ -74,17 +74,21 @@ function getIntegrationFunctionNames(integration) {
74
74
  }
75
75
 
76
76
  /**
77
- * Admin-script functions, when the feature is on (mirrors
78
- * AdminScriptBuilder.shouldExecute). Both can instantiate arbitrary
79
- * integrations, so they belong in every integration's queue-URL consumer
80
- * set.
77
+ * Admin-script functions, when AdminScriptBuilder creates them: the app
78
+ * declares admin scripts, or turns on the built-in scripts. Both can
79
+ * instantiate arbitrary integrations, so they belong in every
80
+ * integration's queue-URL consumer set.
81
81
  *
82
82
  * @param {Object} appDefinition
83
83
  * @returns {string[]}
84
84
  */
85
85
  function getAdminFunctionNames(appDefinition = {}) {
86
- return Array.isArray(appDefinition.adminScripts) &&
87
- appDefinition.adminScripts.length > 0
86
+ const hasAppScripts =
87
+ Array.isArray(appDefinition.adminScripts) &&
88
+ appDefinition.adminScripts.length > 0;
89
+ const hasBuiltinScripts =
90
+ appDefinition.admin?.includeBuiltinScripts === true;
91
+ return hasAppScripts || hasBuiltinScripts
88
92
  ? ['adminScriptRouter', 'adminScriptExecutor']
89
93
  : [];
90
94
  }
@@ -92,6 +92,15 @@ describe('function-environments', () => {
92
92
  expect(getAdminFunctionNames({})).toEqual([]);
93
93
  expect(getAdminFunctionNames({ adminScripts: [] })).toEqual([]);
94
94
  });
95
+
96
+ it('returns the admin functions when only the built-in scripts are on', () => {
97
+ expect(
98
+ getAdminFunctionNames({ admin: { includeBuiltinScripts: true } })
99
+ ).toEqual(['adminScriptRouter', 'adminScriptExecutor']);
100
+ expect(
101
+ getAdminFunctionNames({ admin: { includeBuiltinScripts: false } })
102
+ ).toEqual([]);
103
+ });
95
104
  });
96
105
 
97
106
  describe('applyFunctionEnvironments', () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/devtools",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.744.9a69fb7.0",
4
+ "version": "2.0.0--canary.744.e18e27f.0",
5
5
  "bin": {
6
6
  "frigg": "./frigg-cli/index.js"
7
7
  },
@@ -28,9 +28,9 @@
28
28
  "@babel/eslint-parser": "^7.18.9",
29
29
  "@babel/parser": "^7.25.3",
30
30
  "@babel/traverse": "^7.25.3",
31
- "@friggframework/core": "2.0.0--canary.744.9a69fb7.0",
32
- "@friggframework/schemas": "2.0.0--canary.744.9a69fb7.0",
33
- "@friggframework/test": "2.0.0--canary.744.9a69fb7.0",
31
+ "@friggframework/core": "2.0.0--canary.744.e18e27f.0",
32
+ "@friggframework/schemas": "2.0.0--canary.744.e18e27f.0",
33
+ "@friggframework/test": "2.0.0--canary.744.e18e27f.0",
34
34
  "@hapi/boom": "^10.0.1",
35
35
  "@inquirer/prompts": "^5.3.8",
36
36
  "axios": "^1.18.0",
@@ -58,8 +58,8 @@
58
58
  "validate-npm-package-name": "^5.0.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@friggframework/eslint-config": "2.0.0--canary.744.9a69fb7.0",
62
- "@friggframework/prettier-config": "2.0.0--canary.744.9a69fb7.0",
61
+ "@friggframework/eslint-config": "2.0.0--canary.744.e18e27f.0",
62
+ "@friggframework/prettier-config": "2.0.0--canary.744.e18e27f.0",
63
63
  "aws-sdk-client-mock": "^4.1.0",
64
64
  "aws-sdk-client-mock-jest": "^4.1.0",
65
65
  "jest": "^30.1.3",
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "9a69fb7c1880d0a1d7575e2e18a9fcf0fc76f37c"
94
+ "gitHead": "e18e27f133f0afa7723d361b61ef8e7e80a830ef"
95
95
  }