@servable/tools 2.0.0 → 2.1.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.
Files changed (104) hide show
  1. package/global.d.ts +13 -0
  2. package/package.json +17 -15
  3. package/src/domain/protocolInstance/factory/index.js +8 -4
  4. package/src/domain/protocolInstance/index.js +15 -2
  5. package/src/domain/protocolLoader/base.js +19 -0
  6. package/src/domain/protocolLoader/v1.0.0.js +6 -3
  7. package/src/domain/protocolLoader/v1.1.0.js +7 -4
  8. package/src/domain/servable/parse/utils/index.js +21 -6
  9. package/src/index.js +8 -0
  10. package/src/lib/defineConfig.js +94 -0
  11. package/src/lib/directoryFilesRecursive.js +9 -1
  12. package/src/lib/directoryGlob.js +15 -1
  13. package/src/lib/ensureDirectoryExists.js +18 -5
  14. package/src/lib/getModuleDir.js +8 -3
  15. package/src/manifest/access/index.js +21 -0
  16. package/src/manifest/extract/extractItem.js +1 -1
  17. package/src/manifest/extract/route/extractFiles.js +8 -4
  18. package/src/manifest/extract/route/imageToBase64.js +12 -0
  19. package/src/schema/build/buildProtocol/classStruct/preserveMostRestricted.js +16 -2
  20. package/src/schema/build/index.js +4 -1
  21. package/src/schema/protocolResources/generateTypes.js +106 -0
  22. package/src/schema/protocolResources/index.js +103 -0
  23. package/src/schema/types/index.js +97 -0
  24. package/src/schema/validate/index.js +0 -1
  25. package/types/config/candidates/index.d.ts +2 -0
  26. package/types/config/candidates/protocolCandidates/index.d.ts +9 -0
  27. package/types/config/index.d.ts +2 -0
  28. package/types/config/validate/index.d.ts +4 -0
  29. package/types/config/validate/protocol/index.d.ts +5 -0
  30. package/types/document/gateway/all/index.d.ts +2 -0
  31. package/types/document/gateway/generateGithubReadme/index.d.ts +2 -0
  32. package/types/domain/lib/checkFileExists.d.ts +2 -0
  33. package/types/domain/protocol/factory/absoluteModuleSrcPath.d.ts +2 -0
  34. package/types/domain/protocol/factory/index.d.ts +7 -0
  35. package/types/domain/protocol/factory/protocolPath.d.ts +2 -0
  36. package/types/domain/protocol/index.d.ts +34 -0
  37. package/types/domain/protocol/lib/instancesPathIdUniqueId.d.ts +5 -0
  38. package/types/domain/protocolInstance/factory/getLoaderWithPayload.d.ts +4 -0
  39. package/types/domain/protocolInstance/factory/index.d.ts +6 -0
  40. package/types/domain/protocolInstance/factory/instancesWithPath.d.ts +6 -0
  41. package/types/domain/protocolInstance/index.d.ts +71 -0
  42. package/types/domain/protocolLoader/base.d.ts +52 -0
  43. package/types/domain/protocolLoader/factory/getModule.d.ts +6 -0
  44. package/types/domain/protocolLoader/factory/index.d.ts +4 -0
  45. package/types/domain/protocolLoader/lib/importJSDefault.d.ts +6 -0
  46. package/types/domain/protocolLoader/lib/importJSONDefault.d.ts +6 -0
  47. package/types/domain/protocolLoader/lib/mergeClassProtocols.d.ts +6 -0
  48. package/types/domain/protocolLoader/lib/triggerItems.d.ts +2 -0
  49. package/types/domain/protocolLoader/v1.0.0.d.ts +68 -0
  50. package/types/domain/protocolLoader/v1.1.0.d.ts +70 -0
  51. package/types/domain/servable/index.d.ts +8 -0
  52. package/types/domain/servable/parse/index.d.ts +5 -0
  53. package/types/domain/servable/parse/utils/index.d.ts +41 -0
  54. package/types/index.d.ts +22 -0
  55. package/types/lib/adaptConfig/basic.d.ts +4 -0
  56. package/types/lib/adaptProtocolPayload.d.ts +2 -0
  57. package/types/lib/checkFileExists.d.ts +2 -0
  58. package/types/lib/cleanProtocols.d.ts +2 -0
  59. package/types/lib/defineConfig.d.ts +175 -0
  60. package/types/lib/directories.d.ts +9 -0
  61. package/types/lib/directoryFilesRecursive.d.ts +7 -0
  62. package/types/lib/directoryGlob.d.ts +5 -0
  63. package/types/lib/ensureDirectoryExists.d.ts +15 -0
  64. package/types/lib/foldersInFolder.d.ts +9 -0
  65. package/types/lib/getModuleDir.d.ts +2 -0
  66. package/types/lib/importFileAsText.d.ts +2 -0
  67. package/types/lib/importJSONAsync.d.ts +2 -0
  68. package/types/lib/protocolApiVersion.d.ts +4 -0
  69. package/types/lib/sanitize.d.ts +2 -0
  70. package/types/lib/stableStringify.d.ts +2 -0
  71. package/types/manifest/access/accessChildInTreeWithRoute.d.ts +5 -0
  72. package/types/manifest/access/index.d.ts +10 -0
  73. package/types/manifest/data/1.0.0/enums.d.ts +382 -0
  74. package/types/manifest/data/1.1.0/enums.d.ts +401 -0
  75. package/types/manifest/extract/extractAst.d.ts +2 -0
  76. package/types/manifest/extract/extractItem.d.ts +2 -0
  77. package/types/manifest/extract/formatFile.d.ts +4 -0
  78. package/types/manifest/extract/index.d.ts +8 -0
  79. package/types/manifest/extract/route/extractFileWithVariants.d.ts +2 -0
  80. package/types/manifest/extract/route/extractFiles.d.ts +2 -0
  81. package/types/manifest/extract/route/imageToBase64.d.ts +13 -0
  82. package/types/manifest/extract/route/index.d.ts +2 -0
  83. package/types/manifest/extract/templateDataForId.d.ts +5 -0
  84. package/types/schema/artifact/index.d.ts +21 -0
  85. package/types/schema/build/buildProtocol/classStruct/extractProtocolsProtocols.d.ts +6 -0
  86. package/types/schema/build/buildProtocol/classStruct/index.d.ts +15 -0
  87. package/types/schema/build/buildProtocol/classStruct/preserveMostRestricted.d.ts +4 -0
  88. package/types/schema/build/buildProtocol/classStruct/protocolInClassClassSchema.d.ts +2 -0
  89. package/types/schema/build/buildProtocol/extractClassesProtocol.d.ts +8 -0
  90. package/types/schema/build/buildProtocol/index.d.ts +7 -0
  91. package/types/schema/build/buildProtocol/index.for.d.ts +7 -0
  92. package/types/schema/build/buildProtocol/index.promiseall.d.ts +7 -0
  93. package/types/schema/build/index.d.ts +9 -0
  94. package/types/schema/build/lib/getProtocolsLiveClasses.d.ts +4 -0
  95. package/types/schema/build/lib/updateProtocolsExcerpt.d.ts +5 -0
  96. package/types/schema/plan/classifyField.d.ts +23 -0
  97. package/types/schema/plan/index.d.ts +11 -0
  98. package/types/schema/protocolResources/generateTypes.d.ts +11 -0
  99. package/types/schema/protocolResources/index.d.ts +42 -0
  100. package/types/schema/types/index.d.ts +18 -0
  101. package/types/schema/validate/handleProtocol/computeVersions.d.ts +16 -0
  102. package/types/schema/validate/handleProtocol/index.d.ts +18 -0
  103. package/types/schema/validate/index.d.ts +26 -0
  104. package/src/schema/index.js +0 -56
package/global.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ // lucide (PEAKUB DX initiative): a small handful of files in this package (mostly
2
+ // `src/domain/servable/parse/utils/` and `src/schema/build/buildProtocol/`) reference the
3
+ // runtime-global `Servable` object that `@servable/server` sets up (`global.Servable = new
4
+ // ServableClass()`) - this package is a dependency OF `@servable/server`, not the other way
5
+ // around, so it can't import that package's own (more precise) ambient declaration without an
6
+ // upside-down dependency. `any` here is a deliberate, honest ceiling: `@servable/server`'s own
7
+ // `global.d.ts` is the real source of truth for what `Servable` actually looks like at runtime.
8
+ declare global {
9
+ // eslint-disable-next-line no-var
10
+ var Servable: any
11
+ }
12
+
13
+ export {}
package/package.json CHANGED
@@ -3,7 +3,8 @@
3
3
  "type": "module",
4
4
  "source": "src/index.js",
5
5
  "main": "src/index.js",
6
- "version": "2.0.0",
6
+ "types": "types/index.d.ts",
7
+ "version": "2.1.0",
7
8
  "description": "Servable tools is a utility that builds a protocol's manifest and documents it.",
8
9
  "author": "Servable Community",
9
10
  "license": "ISC",
@@ -13,10 +14,12 @@
13
14
  "homepage": "https://github.com/servable-core/tools#readme",
14
15
  "files": [
15
16
  "dist",
16
- "src"
17
+ "src",
18
+ "types",
19
+ "global.d.ts"
17
20
  ],
18
21
  "engines": {
19
- "node": ">=10"
22
+ "node": ">=20"
20
23
  },
21
24
  "config": {
22
25
  "commitizen": {
@@ -28,6 +31,8 @@
28
31
  },
29
32
  "scripts": {
30
33
  "test_": "echo \"Error: no test specified\" && exit 1",
34
+ "build:types": "tsc",
35
+ "test:types": "tsc --noEmit",
31
36
  "semantic-release": "semantic-release",
32
37
  "acp": "git add . && npm run commit && git push",
33
38
  "commit": "git-cz",
@@ -75,32 +80,29 @@
75
80
  "fs-extra": "^11.2.0",
76
81
  "fse": "^4.0.1",
77
82
  "git-url-parse": "^13.1.1",
83
+ "jimp": "^1.6.0",
78
84
  "json2md": "^2.0.0",
79
85
  "mime": "^4.0.0",
80
86
  "parse-comments": "^1.0.0",
81
87
  "path-sanitizer": "^3.1.0",
82
88
  "semver": "^7.5.4",
83
- "jimp": "^1.6.0",
84
89
  "underscore": "^1.13.3"
85
90
  },
86
91
  "devDependencies": {
92
+ "@eslint/js": "^9",
87
93
  "@size-limit/preset-small-lib": "^4.10.2",
88
94
  "cz-conventional-changelog": "^3.3.0",
89
- "eslint": "^6.8.0",
90
- "eslint-config-prettier": "^6.7.0",
91
- "eslint-config-standard": "^14.1.0",
92
- "eslint-config-standard-react": "^9.2.0",
93
- "eslint-plugin-import": "^2.18.2",
94
- "eslint-plugin-node": "^11.0.0",
95
- "eslint-plugin-prettier": "^3.1.1",
96
- "eslint-plugin-promise": "^4.2.1",
97
- "eslint-plugin-react": "^7.17.0",
98
- "eslint-plugin-standard": "^4.0.1",
95
+ "eslint": "^9",
96
+ "eslint-config-prettier": "^9",
97
+ "eslint-plugin-jsdoc": "^50",
98
+ "eslint-plugin-n": "^17",
99
+ "globals": "^15",
99
100
  "husky": "^6.0.0",
100
101
  "jest": "^29.7.0",
101
102
  "npm-run-all": "^4.1.5",
102
103
  "prettier": "^2.0.4",
103
104
  "semantic-release": "^23.0.0",
104
- "size-limit": "^4.10.2"
105
+ "size-limit": "^4.10.2",
106
+ "typescript": "^5"
105
107
  }
106
108
  }
@@ -9,7 +9,9 @@ export const getWithCache = async ({
9
9
  instances,
10
10
  }) => {
11
11
 
12
- const { id, module, version, path } = protocolPayload
12
+ // `id`/`module`/`version` (also destructured here previously) were never read anywhere in
13
+ // this function - trimmed (found via eslint's `no-unused-vars`, lucide/PEAKUB DX initiative).
14
+ const { path } = protocolPayload
13
15
 
14
16
  if (!instancesPathId || !instancesPathId.length) {
15
17
  return null
@@ -19,12 +21,14 @@ export const getWithCache = async ({
19
21
  let { type, value: { className } } = instancePathOfInterest
20
22
 
21
23
  switch (type) {
22
- case 'class': {
23
- } break
24
+ // No override needed: `className` is already correct from the destructure above.
25
+ case 'class':
26
+ break
24
27
  case 'protocol': {
25
28
  if (instancePathOfInterest.value.id === 'app') {
26
29
  className = '_root'
27
- } break
30
+ }
31
+ break
28
32
  }
29
33
  default: {
30
34
  return null
@@ -42,6 +42,11 @@ export default class ProtocolInstance {
42
42
  console.log("[@servable/tools/domain/protocolInstance] constructor() → Protocol instance initialized with ID:", this._id, "Unique path ID:", this._instancesPathIdString)
43
43
  }
44
44
 
45
+ /**
46
+ * @param {object} [props]
47
+ * @param {object} [props.servableConfig] - used to resolve a pinned version for this
48
+ * protocol instance from `servableConfig.versions`, if present.
49
+ */
45
50
  async load({ servableConfig } = {}) {
46
51
  switch (this.loadState) {
47
52
  case 1: {
@@ -192,8 +197,16 @@ export default class ProtocolInstance {
192
197
  }
193
198
 
194
199
  // #region loader
195
- async schemaRaw({ ad } = {}) {
196
- return this.loader.schemaRaw({ ad: 43 })
200
+ /**
201
+ * @returns {Promise<object | null>} this protocol instance's raw `schema.json`
202
+ * contents, memoized by the loader.
203
+ */
204
+ async schemaRaw() {
205
+ // The loader's own schemaRaw() ignores whatever argument it's given (confirmed: no
206
+ // reference to it in either v1.0.0.js's or v1.1.0.js's implementation) - this used to
207
+ // forward a hardcoded, unused `{ ad: 43 }` here, which was equally inert. Simplified
208
+ // rather than left as a misleading no-op parameter.
209
+ return this.loader.schemaRaw()
197
210
  }
198
211
  // #endregion
199
212
  }
@@ -40,6 +40,12 @@ export default class ProtocolLoader {
40
40
 
41
41
 
42
42
 
43
+ /**
44
+ * @param {object} [props]
45
+ * @param {object} [props.servableConfig] - currently unused by this base
46
+ * implementation; accepted for interface parity with the loader subclasses that do
47
+ * read it (e.g. version resolution).
48
+ */
43
49
  async loadExtraction({ servableConfig } = {}) {
44
50
  try {
45
51
  this.extraction = await extract({
@@ -88,10 +94,23 @@ export default class ProtocolLoader {
88
94
  return mo.data.module
89
95
  }
90
96
 
97
+ /**
98
+ * @param {object} props
99
+ * @param {string} props.path
100
+ * @param {string} [props.cacheKey] - most callers omit this. Note:
101
+ * `importJSDefault`/`importJSONDefault` currently accept `cache`/`cacheKey` but never
102
+ * read them - every call is a fresh dynamic `import()`, not actually cached. Caching
103
+ * in this class goes through the separate `_valueInCache`/`this.cache` mechanism
104
+ * instead (see e.g. `classFunctions()`).
105
+ */
91
106
  async _importJSDefault({ path, cacheKey }) {
92
107
  return importJSDefault({ path, cache: this._cache, cacheKey })
93
108
  }
94
109
 
110
+ /** @param {object} props
111
+ * @param {string} props.path
112
+ * @param {string} [props.cacheKey] - see `_importJSDefault`'s note; unused today.
113
+ */
95
114
  async _importJSONDefault({ path, cacheKey }) {
96
115
  return importJSONDefault({ path, cache: this._cache, cacheKey })
97
116
  }
@@ -645,7 +645,10 @@ export default class ProtocolLoaderV1_0_0 extends BaseClass {
645
645
  // return this.valueInCache(cacheKey)
646
646
  // }
647
647
 
648
- const schemaPath = await this._schemaPath()
648
+ // Was: `const schemaPath = await this._schemaPath()` - dead, both because this whole
649
+ // method is obsolete (`_obs`) and because `_schemaPath` was never defined on this
650
+ // class; the result was never read either. Removed rather than "fixed" since there's
651
+ // nothing here to preserve.
649
652
  const path = `${this.configDirPath_obs()}/index.json`
650
653
 
651
654
  if (!(await checkFileExists(path))) {
@@ -743,7 +746,7 @@ export default class ProtocolLoaderV1_0_0 extends BaseClass {
743
746
 
744
747
  let _data = (await directoryGlob({
745
748
  path: `${__path}/**/*.js`, globOptions: {
746
- mark: true,
749
+ markDirectories: true,
747
750
  ignore: ['**/lib/**']
748
751
  }
749
752
  }))
@@ -762,7 +765,7 @@ export default class ProtocolLoaderV1_0_0 extends BaseClass {
762
765
 
763
766
  const data = (await directoryGlob({
764
767
  path: `${path}/**/*.js`, globOptions: {
765
- mark: true,
768
+ markDirectories: true,
766
769
  ignore: ['**/lib/**']
767
770
  }
768
771
  }))
@@ -644,7 +644,10 @@ export default class ProtocolLoaderV1_1_0 extends BaseClass {
644
644
  // return this.valueInCache(cacheKey)
645
645
  // }
646
646
 
647
- const schemaPath = await this._schemaPath()
647
+ // Was: `const schemaPath = await this._schemaPath()` - dead, both because this whole
648
+ // method is obsolete (`_obs`) and because `_schemaPath` was never defined on this
649
+ // class; the result was never read either. Removed rather than "fixed" since there's
650
+ // nothing here to preserve.
648
651
  const path = `${this.configDirPath_obs()}/index.json`
649
652
 
650
653
  if (!(await checkFileExists(path))) {
@@ -743,7 +746,7 @@ export default class ProtocolLoaderV1_1_0 extends BaseClass {
743
746
 
744
747
  let _data = (await directoryGlob({
745
748
  path: `${__path}/**/*.js`, globOptions: {
746
- mark: true,
749
+ markDirectories: true,
747
750
  ignore: ['**/lib/**']
748
751
  }
749
752
  }))
@@ -762,7 +765,7 @@ export default class ProtocolLoaderV1_1_0 extends BaseClass {
762
765
 
763
766
  const data = (await directoryGlob({
764
767
  path: `${path}/**/*.js`, globOptions: {
765
- mark: true,
768
+ markDirectories: true,
766
769
  ignore: ['**/lib/**']
767
770
  }
768
771
  }))
@@ -777,7 +780,7 @@ export default class ProtocolLoaderV1_1_0 extends BaseClass {
777
780
 
778
781
  const data = (await directoryGlob({
779
782
  path: `${path}/**/*.js`, globOptions: {
780
- mark: true,
783
+ markDirectories: true,
781
784
  ignore: ['**/lib/**']
782
785
  }
783
786
  }))
@@ -1,3 +1,11 @@
1
+ // @ts-nocheck - lucide (PEAKUB DX initiative): a grab-bag of Parse-specific runtime helpers
2
+ // that read the global `Servable.App.*` surface with heavily overloaded/optional-property
3
+ // param shapes (checkJs infers stricter object types from each call site's own usage than
4
+ // the code actually intends). Deferred rather than annotated file-wide here; a future pass
5
+ // should type each function's real param shape individually instead of suppressing the
6
+ // whole file.
7
+ import fs from 'fs'
8
+
1
9
  export const getOnePlain = async props => {
2
10
  const { objectId, className, useMasterKey = false } = props;
3
11
  const query = new Servable.App.Query(className);
@@ -221,13 +229,20 @@ export const saveFileDataToFS = async ({ file, path = "temp/files" }) => {
221
229
  return null;
222
230
  }
223
231
 
224
- const dirPath = "/uploads";
225
- if (!fs.existsSync()) {
226
- await fs.promises.mkdir(dirPath);
227
- }
228
-
229
- const filePath = `${dirPath}/${file.name}`;
232
+ // Found via eslint's `no-undef` (`fs` was never imported at all, so this threw a
233
+ // ReferenceError into the catch below on every call) then confirmed against the identical,
234
+ // already-fixed bug in @servable/parse-server-engine's own copy of this function (lucide,
235
+ // PEAKUB DX initiative). Also fixed here: `dirPath` hardcoded to "/uploads" instead of using
236
+ // the real `path` parameter, and `fs.existsSync()` called with no argument (always `false`,
237
+ // so `mkdir` ran unguarded every call and threw EEXIST once the directory already existed -
238
+ // itself swallowed by the same catch). `recursive: true` replaces the existence check
239
+ // entirely rather than fixing the missing argument, matching the engine's fix.
240
+ await fs.promises.mkdir(path, { recursive: true });
241
+
242
+ const filePath = `${path}/${file.name}`;
230
243
  await fs.promises.writeFile(filePath, data);
244
+ // Returned so a caller can tell success from the null returned on every failure path.
245
+ return filePath;
231
246
  } catch (e) {
232
247
  console.error(e);
233
248
  return null;
package/src/index.js CHANGED
@@ -7,12 +7,16 @@ import buildSchema from './schema/build/index.js'
7
7
  import validateSchema from './schema/validate/index.js'
8
8
  import compileArtifact, { hashOf as artifactHashOf, normalizeArtifact } from './schema/artifact/index.js'
9
9
  import plan from './schema/plan/index.js'
10
+ import generateSchemaTypes from './schema/types/index.js'
11
+ import buildProtocolResources from './schema/protocolResources/index.js'
12
+ import generateProtocolResourceTypes from './schema/protocolResources/generateTypes.js'
10
13
  // import validateProtocol from './lib/config/validate/protocol/index.js'
11
14
  import cleanProtocols from './lib/cleanProtocols.js'
12
15
 
13
16
 
14
17
  import documentProtocol from './document/gateway/all/index.js'
15
18
  import generateGithubReadme from './document/gateway/generateGithubReadme/index.js'
19
+ import defineConfig from './lib/defineConfig.js'
16
20
 
17
21
  import Servable from './domain/servable/index.js'
18
22
  const Domain = { Servable }
@@ -29,7 +33,11 @@ export {
29
33
  artifactHashOf,
30
34
  normalizeArtifact,
31
35
  plan,
36
+ generateSchemaTypes,
37
+ buildProtocolResources,
38
+ generateProtocolResourceTypes,
32
39
  cleanProtocols,
33
40
  generateGithubReadme,
41
+ defineConfig,
34
42
  Domain
35
43
  }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @typedef {object} ServableDockerConfig
3
+ * @property {boolean} [enabled] - whether local docker-compose orchestration runs at all.
4
+ * Defaults to `true`.
5
+ * @property {string[]} [environments] - which `NODE_ENV` values this applies to. Defaults
6
+ * to `['development']`.
7
+ * @property {string} [namespace] - isolates this worktree's docker-compose stack (project
8
+ * name and any explicit `container_name`) from another worktree of the same app running
9
+ * at the same time. Unset (the default) is a complete no-op.
10
+ */
11
+
12
+ /**
13
+ * @typedef {object} ServableSystemConfig
14
+ * @property {ServableDockerConfig} [docker]
15
+ */
16
+
17
+ /**
18
+ * @typedef {object} ServableCorsConfig
19
+ * @property {string[]} [allowedOrigins] - static allow-list.
20
+ * @property {(hostname: string) => boolean} [isOriginAllowed] - dynamic check, e.g. for a
21
+ * custom-domains feature backed by a verified-domains store. Runs in addition to
22
+ * `allowedOrigins`, not instead of it.
23
+ */
24
+
25
+ /**
26
+ * Passed almost as-is to the underlying Parse Server instance - see that engine's own
27
+ * `doLaunch()` for the full set of keys it actually reads (`mongoOptions`, `auth`,
28
+ * `sessionLength`, `masterKeyIps`, etc). Only the ones every app is likely to set are
29
+ * named below; the `Record<string, any>` intersection keeps any other Parse Server option
30
+ * from being rejected.
31
+ *
32
+ * @typedef {{
33
+ * sessionLength?: number,
34
+ * masterKeyIps?: string[],
35
+ * auth?: object,
36
+ * } & Record<string, any>} ServableParseConfig
37
+ */
38
+
39
+ /**
40
+ * @typedef {object} ServableAppConfig
41
+ * @property {ServableCorsConfig} [cors]
42
+ * @property {ServableParseConfig} [parse]
43
+ */
44
+
45
+ /**
46
+ * @typedef {object} ServableConfiguration
47
+ * @property {ServableAppConfig} [config]
48
+ */
49
+
50
+ /**
51
+ * @typedef {object} ServableDryRunConfig
52
+ * @property {boolean} [enabled]
53
+ * @property {string[]} [environments] - which `NODE_ENV` values dry-run applies to.
54
+ * @property {{ users?: Array<{ email?: string, id?: string, phoneNumber?: string }> }} [exceptions] -
55
+ * accounts exempted from dry-run behavior even when it's on.
56
+ */
57
+
58
+ /**
59
+ * The shape `servable.config.js` exports as its default. Every field is optional -
60
+ * `@servable/server`'s own `adaptConfig` fills in defaults for whatever's missing (see
61
+ * `lib/adaptConfig/basic.js`) - this type exists purely for editor autocomplete on the file
62
+ * an app author actually hand-writes, not as a runtime schema.
63
+ *
64
+ * @typedef {object} ServableConfig
65
+ * @property {string} id - this app's identity (not a per-checkout/worktree identity -
66
+ * stays the same across worktrees of the same app).
67
+ * @property {ServableSystemConfig} [system]
68
+ * @property {ServableConfiguration} [configuration]
69
+ * @property {ServableDryRunConfig} [dryRun]
70
+ * @property {string[]} [protocols] - additional local protocol search paths, prepended to
71
+ * (not replacing) the framework's own bundled protocols and the app's own `protocols/`.
72
+ */
73
+
74
+ /**
75
+ * Identity helper for `servable.config.js` - returns `config` completely unchanged. Its
76
+ * only purpose is to give the object literal a known type, the same pattern
77
+ * Vite/Next.js/Docusaurus use their own `defineConfig()` for: wrap the export, get
78
+ * autocomplete and inline docs on every field, no runtime behavior added.
79
+ *
80
+ * @example
81
+ * // servable.config.js
82
+ * import { defineConfig } from '@servable/tools'
83
+ *
84
+ * export default defineConfig({
85
+ * id: 'my-app',
86
+ * system: { docker: { namespace: 'my-epic' } },
87
+ * })
88
+ *
89
+ * @param {ServableConfig} config
90
+ * @returns {ServableConfig} the same `config`, unmodified.
91
+ */
92
+ export default function defineConfig(config) {
93
+ return config
94
+ }
@@ -33,7 +33,15 @@ const perform = async ({ path,
33
33
 
34
34
  const isDir = _stat.isDirectory()
35
35
  if (isDir) {
36
- return perform({ path: __path })
36
+ // Was `perform({ path: __path })` - dropped `includeMeta`/`excludes`/`includeExtensions`
37
+ // on every recursive descent, silently resetting them to their defaults for anything in
38
+ // a subdirectory. With `includeMeta: true` that meant a nested file's entry came back as
39
+ // the bare imported module (no `{ module, path, documentation }` wrapper) - indistinguishable
40
+ // in shape from a caller reading `.module`/`.path` off it, which would just see
41
+ // `undefined` rather than an error (found via a real fixture test in
42
+ // @servable/tools' buildProtocolResources(), lucide/PEAKUB DX initiative - protocols
43
+ // really do nest resources in subdirectories, e.g. services/payout/finak/request.js).
44
+ return perform({ path: __path, includeMeta, excludes, includeExtensions })
37
45
  }
38
46
 
39
47
  if (!(await checkFileExists(__path))) {
@@ -1,10 +1,24 @@
1
1
  import fg from 'fast-glob'
2
2
 
3
+ /**
4
+ * Globs `path`, then dynamically imports every matching file, skipping test files and a
5
+ * few common internal directories by default.
6
+ *
7
+ * @param {object} props
8
+ * @param {string} props.path - a glob pattern.
9
+ * @param {import('fast-glob').Options} [props.globOptions] - forwarded to `fast-glob`;
10
+ * its `ignore` patterns are unioned with (not replaced by) the defaults.
11
+ * @returns {Promise<any[] | null>} the imported modules' default exports, or `null` on
12
+ * any error (logged, not thrown).
13
+ */
3
14
  export default async ({ path, globOptions = {} }) => {
4
15
  try {
5
16
  // Default options to skip test files and common internal dirs
6
17
  const defaultOptions = {
7
- mark: true,
18
+ // Was `mark: true` - fast-glob's real option name is `markDirectories` (found via
19
+ // checkJs earlier in the lucide/PEAKUB DX initiative for this same option in
20
+ // protocolLoader's own directoryGlob calls; missed in this shared utility at the time).
21
+ markDirectories: true,
8
22
  ignore: [
9
23
  '**/lib/**',
10
24
  '**/__tests__/**',
@@ -1,14 +1,27 @@
1
1
  import fs from 'fs'
2
2
  import path from 'path'
3
- import checkFileExists from './checkFileExists'
3
+ import checkFileExists from './checkFileExists.js'
4
4
 
5
+ /**
6
+ * Ensures the directory containing `filePath` exists, creating any missing
7
+ * parent directories along the way (like `mkdir -p`).
8
+ *
9
+ * Found via `checkJs` (lucide, PEAKUB DX initiative): the two-line body used to
10
+ * call an undefined `ensureDirectoryExistence` and import `./checkFileExists`
11
+ * with no extension - the latter throws `ERR_MODULE_NOT_FOUND` under Node ESM,
12
+ * so this function has never actually worked. Nothing in this package calls it
13
+ * today (confirmed via a repo-wide grep), so the bug was latent, not live.
14
+ *
15
+ * @param {string} filePath - a file path whose parent directory should exist.
16
+ * @returns {Promise<true>} resolves once the directory exists (or already did).
17
+ */
5
18
  const operation = async filePath => {
6
- var dirname = path.dirname(filePath)
7
- if (!(await checkFileExists(dirname))) {
19
+ const dirname = path.dirname(filePath)
20
+ if (await checkFileExists(dirname)) {
8
21
  return true
9
22
  }
10
- ensureDirectoryExistence(dirname)
11
- fs.promises.mkdir(dirname)
23
+ await fs.promises.mkdir(dirname, { recursive: true })
24
+ return true
12
25
  }
13
26
 
14
27
  export default operation
@@ -3,9 +3,14 @@ import path from 'path'
3
3
  import { createRequire } from 'module'
4
4
 
5
5
  /**
6
- * Get's the file path to a module folder.
7
- * @param {string} moduleEntry
8
- * @param {string} fromFile
6
+ * Resolves the on-disk root folder of an installed npm package (not the specific
7
+ * entry file `require.resolve` would return), by walking Node's own module
8
+ * lookup paths for `moduleEntry` and returning the first one that exists.
9
+ *
10
+ * @param {string} moduleEntry - a bare package specifier, e.g. `'@servable/server'`
11
+ * or `'@servable/server/package.json'`; only the package name portion is used.
12
+ * @returns {string | undefined} the package's root directory, or `undefined` if
13
+ * it can't be found in any lookup path.
9
14
  */
10
15
  export default (moduleEntry) => {
11
16
  const packageName = moduleEntry.includes('/')
@@ -3,6 +3,27 @@ import accessChildInTreeWithRoute from './accessChildInTreeWithRoute.js'
3
3
  import sanitizePath from '../../lib/sanitize.js'
4
4
  import { DataTemplateType } from '../data/1.0.0/enums.js'
5
5
 
6
+ /**
7
+ * Reads one item (by manifest route, e.g. a schema, a class, a config file) out of a
8
+ * protocol's manifest tree, either from an already-extracted tree or by extracting
9
+ * `path` itself first.
10
+ *
11
+ * @param {object} props
12
+ * @param {string} [props.path] - protocol root to extract from, if `extraction` isn't
13
+ * already provided.
14
+ * @param {string} [props.variant] - manifest variant to read, when the item has more
15
+ * than one (engine-specific).
16
+ * @param {string} [props.mimeType] - for file-type items, filters results to this mime
17
+ * type.
18
+ * @param {string} props.item - the `ProtocolEnum` route identifying what to read.
19
+ * @param {string} [props.type] - the extraction's `DataTemplateType`. Defaults to
20
+ * `DataTemplateType.Protocol`.
21
+ * @param {boolean} [props.formatData] - post-process file-type results (mime filtering,
22
+ * single-vs-array collapsing). Defaults to `true`.
23
+ * @param {object} [props.extraction] - an already-extracted manifest tree, to skip
24
+ * re-extracting `path`.
25
+ * @returns {Promise<object | null>} the manifest item's data, or `null` if not found.
26
+ */
6
27
  export default async ({
7
28
  path,
8
29
  variant,
@@ -41,7 +41,7 @@ const performItem = async (props) => {
41
41
  const templateData = await templateDataForId({ id: templateId, path: props.parentLeafPath })
42
42
 
43
43
  result.children = await Promise.all(computed.templateCollection.folders.map(async (folder, index) => {
44
- const { stat, name } = folder
44
+ const { name } = folder
45
45
  return performItem({
46
46
  ...props,
47
47
  item: templateData,
@@ -1,3 +1,7 @@
1
+ // @ts-nocheck - lucide (PEAKUB DX initiative): the sharp resize helper this file calls is
2
+ // typed with several required options that this caller passes conditionally/optionally.
3
+ // Deferred rather than annotated here; see imageToBase64.js's own note for the same
4
+ // image-processing-library friction.
1
5
  import checkFileExists from "../../../lib/checkFileExists.js"
2
6
  import importJSONAsync from "../../../lib/importJSONAsync.js"
3
7
  import sanitizePath from '../../../lib/sanitize.js'
@@ -66,10 +70,10 @@ export default async (props) => {
66
70
  moduleImporter = async ({ path }) => importJSONAsync(path)
67
71
  break
68
72
  }
69
- case 'text/yaml': {
70
- moduleImporter = async ({ path }) => fse.readFile(path, 'utf8')
71
- break
72
- }
73
+ // A duplicate `case 'text/yaml':` used to sit here - 'text/yaml' is already grouped with
74
+ // `default`/`text/markdown` above, so this one was 100% dead (a switch always matches the
75
+ // first case label reached); removed rather than kept, since JS switch fallthrough means it
76
+ // could never run (found via eslint's `no-duplicate-case`, lucide/PEAKUB DX initiative).
73
77
  }
74
78
 
75
79
  const files = await extractFileWithVariants({
@@ -1,3 +1,15 @@
1
+ // @ts-nocheck - lucide (PEAKUB DX initiative): the installed `jimp` v1 types don't match how
2
+ // this file calls the library (static `Jimp.MIME_PNG`-style constants, `.quality()`,
3
+ // `.getBase64Async()` - all real at runtime, just not reflected in the bundled .d.ts).
4
+ // Deferred rather than worked around with per-call casts; a real fix means confirming which
5
+ // jimp API generation this code actually targets and either upgrading the call sites or
6
+ // pinning an older `@types/jimp`.
7
+ //
8
+ // The real resize logic below is an explicit, pre-existing `return null //#TODO` stub (not
9
+ // something this pass introduced or is fixing), so it's genuinely unreachable and its params
10
+ // genuinely unused until someone finishes it for real - disabled below rather than silenced by
11
+ // deleting the stub or guessing at a finished implementation.
12
+ /* eslint-disable no-unreachable, no-unused-vars, jsdoc/require-param-type */
1
13
  import { Jimp } from 'jimp'
2
14
 
3
15
  /**
@@ -87,11 +87,25 @@ const dedupePermission = (a, b) => {
87
87
 
88
88
  keys.forEach(key => {
89
89
  if (key === 'requiresAuthentication') {
90
- result.requiresAuthentication = (a.requiresAuthentication || b.aRequiresAuthentication)
90
+ // Found via eslint (no-prototype-builtins led here; lucide/PEAKUB DX initiative) - two real
91
+ // bugs stacked on this one field, both defeating this function's whole stated purpose
92
+ // ("preserve most restrictive"):
93
+ // 1. `b.aRequiresAuthentication` was a typo for `b.requiresAuthentication` - that
94
+ // property never exists on any real object, so the `||` always fell through to
95
+ // `undefined` unless `a.requiresAuthentication` was already truthy.
96
+ // 2. Even fixed, the assignment was entirely dead: with no `return` here, the shared
97
+ // `result[key] = b.hasOwnProperty(key) ? b[key] : a[key]` below ran unconditionally
98
+ // right after for this same key, silently overwriting whatever was just computed.
99
+ // That line implements "b wins if b has the key", which is the OPPOSITE of "most
100
+ // restrictive wins" whenever `a.requiresAuthentication` is `true` and
101
+ // `b.requiresAuthentication` is `false` - the merge would end up NOT requiring
102
+ // authentication for a class where one of the two merged protocols required it.
103
+ result.requiresAuthentication = Boolean(a.requiresAuthentication || b.requiresAuthentication)
91
104
  delete result["*"]
105
+ return
92
106
  }
93
107
 
94
- result[key] = b.hasOwnProperty(key) ? b[key] : a[key]
108
+ result[key] = Object.prototype.hasOwnProperty.call(b, key) ? b[key] : a[key]
95
109
  })
96
110
 
97
111
  return result
@@ -6,7 +6,10 @@ import updateProtocolsExcerpt from './lib/updateProtocolsExcerpt.js'
6
6
 
7
7
  export default async ({ servableConfig }) => {
8
8
  const { rootProtocolPayload } = servableConfig
9
- adaptConfigBasic({ servableConfig, live: false })
9
+ // adaptConfigBasic() only ever reads `servableConfig` - it has no `live` parameter (that
10
+ // flag belongs to @servable/server's own, unrelated adaptConfig() wrapper). Passing it
11
+ // here was inert; removed rather than kept as a misleading no-op argument.
12
+ adaptConfigBasic({ servableConfig })
10
13
  const protocolsCache = []
11
14
  const appProtocol = await protocolFactory({
12
15
  protocolPayload: {