@bluestep-systems/b6p-core 0.4.0 → 0.6.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 (119) hide show
  1. package/README.md +29 -13
  2. package/dist/B6PCore.d.ts +38 -80
  3. package/dist/B6PCore.js +52 -385
  4. package/dist/B6PCore.js.map +1 -1
  5. package/dist/B6PUri.d.ts +147 -7
  6. package/dist/B6PUri.js +190 -12
  7. package/dist/B6PUri.js.map +1 -1
  8. package/dist/Err.js.map +1 -1
  9. package/dist/PlatformContext.d.ts +33 -0
  10. package/dist/PlatformContext.js +3 -0
  11. package/dist/PlatformContext.js.map +1 -0
  12. package/dist/auth/BearerAuthProvider.d.ts +64 -0
  13. package/dist/auth/BearerAuthProvider.js +148 -0
  14. package/dist/auth/BearerAuthProvider.js.map +1 -0
  15. package/dist/cache/OrgCache.d.ts +64 -7
  16. package/dist/cache/OrgCache.js +142 -23
  17. package/dist/cache/OrgCache.js.map +1 -1
  18. package/dist/cache/ScriptMetaDataStore.d.ts +2 -2
  19. package/dist/cache/ScriptMetaDataStore.js.map +1 -1
  20. package/dist/constants/ApiEndpoints.js.map +1 -1
  21. package/dist/constants/AuthTypes.d.ts +0 -1
  22. package/dist/constants/AuthTypes.js +0 -1
  23. package/dist/constants/AuthTypes.js.map +1 -1
  24. package/dist/constants/BlueHQ.js.map +1 -1
  25. package/dist/constants/CryptoAlgorithms.js.map +1 -1
  26. package/dist/constants/ExtensionConfig.js.map +1 -1
  27. package/dist/constants/FileExtensions.js.map +1 -1
  28. package/dist/constants/FolderNames.js.map +1 -1
  29. package/dist/constants/GitHubUrls.js.map +1 -1
  30. package/dist/constants/Http.js.map +1 -1
  31. package/dist/constants/MimeTypes.js.map +1 -1
  32. package/dist/constants/Numerical.js.map +1 -1
  33. package/dist/constants/OutputChannels.js.map +1 -1
  34. package/dist/constants/SettingsKeys.js.map +1 -1
  35. package/dist/constants/SpecialFiles.js.map +1 -1
  36. package/dist/constants/WebDAVElements.js.map +1 -1
  37. package/dist/data/DownstairsPathParser.js.map +1 -1
  38. package/dist/data/GlobMatcher.js.map +1 -1
  39. package/dist/data/IdUtility.d.ts +2 -2
  40. package/dist/data/IdUtility.js.map +1 -1
  41. package/dist/data/OrgWorker.js.map +1 -1
  42. package/dist/data/ScriptKey.js.map +1 -1
  43. package/dist/data/ScriptUrlParser.d.ts +4 -3
  44. package/dist/data/ScriptUrlParser.js +2 -1
  45. package/dist/data/ScriptUrlParser.js.map +1 -1
  46. package/dist/index.d.ts +9 -5
  47. package/dist/index.js +7 -4
  48. package/dist/index.js.map +1 -1
  49. package/dist/network/HttpClient.js.map +1 -1
  50. package/dist/network/HttpClientProvider.js.map +1 -1
  51. package/dist/network/StatusCodes.js.map +1 -1
  52. package/dist/persistence/PersistablePseudoMap.d.ts +4 -4
  53. package/dist/persistence/PersistablePseudoMap.js +1 -1
  54. package/dist/persistence/PersistablePseudoMap.js.map +1 -1
  55. package/dist/persistence/PersistenceKeys.d.ts +0 -4
  56. package/dist/persistence/PersistenceKeys.js +0 -4
  57. package/dist/persistence/PersistenceKeys.js.map +1 -1
  58. package/dist/persistence/PrivatePersistanceMap.d.ts +4 -3
  59. package/dist/persistence/PrivatePersistanceMap.js +2 -1
  60. package/dist/persistence/PrivatePersistanceMap.js.map +1 -1
  61. package/dist/persistence/PseudoMap.js.map +1 -1
  62. package/dist/persistence/PublicPersistanceMap.d.ts +3 -3
  63. package/dist/persistence/PublicPersistanceMap.js +1 -1
  64. package/dist/persistence/PublicPersistanceMap.js.map +1 -1
  65. package/dist/persistence/Serializable.js.map +1 -1
  66. package/dist/persistence/SharedFilePersistence.d.ts +3 -3
  67. package/dist/persistence/SharedFilePersistence.js +1 -1
  68. package/dist/persistence/SharedFilePersistence.js.map +1 -1
  69. package/dist/persistence/TypedMap.js.map +1 -1
  70. package/dist/persistence/TypedPersistable.d.ts +5 -5
  71. package/dist/persistence/TypedPersistable.js +2 -2
  72. package/dist/persistence/TypedPersistable.js.map +1 -1
  73. package/dist/persistence/TypedPrivatePersistable.d.ts +3 -3
  74. package/dist/persistence/TypedPrivatePersistable.js +1 -1
  75. package/dist/persistence/TypedPrivatePersistable.js.map +1 -1
  76. package/dist/persistence/dirLockdown.js.map +1 -1
  77. package/dist/providers.d.ts +48 -14
  78. package/dist/script/ScriptContext.d.ts +17 -16
  79. package/dist/script/ScriptFactory.d.ts +23 -16
  80. package/dist/script/ScriptFactory.js +23 -44
  81. package/dist/script/ScriptFactory.js.map +1 -1
  82. package/dist/script/ScriptFile.d.ts +68 -3
  83. package/dist/script/ScriptFile.js +103 -10
  84. package/dist/script/ScriptFile.js.map +1 -1
  85. package/dist/script/ScriptFolder.d.ts +21 -0
  86. package/dist/script/ScriptFolder.js +28 -4
  87. package/dist/script/ScriptFolder.js.map +1 -1
  88. package/dist/script/ScriptNode.d.ts +15 -0
  89. package/dist/script/ScriptNode.js +35 -1
  90. package/dist/script/ScriptNode.js.map +1 -1
  91. package/dist/script/ScriptRoot.js +10 -6
  92. package/dist/script/ScriptRoot.js.map +1 -1
  93. package/dist/script/ScriptService.d.ts +143 -0
  94. package/dist/script/ScriptService.js +460 -0
  95. package/dist/script/ScriptService.js.map +1 -0
  96. package/dist/script/ScriptTranspiler.js.map +1 -1
  97. package/dist/script/SnapshotHistoryRecorder.d.ts +37 -2
  98. package/dist/script/SnapshotHistoryRecorder.js +82 -26
  99. package/dist/script/SnapshotHistoryRecorder.js.map +1 -1
  100. package/dist/script/TsConfig.js.map +1 -1
  101. package/dist/script/TsLibResolver.js.map +1 -1
  102. package/dist/script/push.d.ts +41 -0
  103. package/dist/{push.js → script/push.js} +23 -13
  104. package/dist/script/push.js.map +1 -0
  105. package/dist/session/SessionManager.d.ts +3 -2
  106. package/dist/session/SessionManager.js.map +1 -1
  107. package/dist/testing/MockFileSystem.d.ts +16 -3
  108. package/dist/testing/MockFileSystem.js +65 -42
  109. package/dist/testing/MockFileSystem.js.map +1 -1
  110. package/dist/testing/TestableFactory.d.ts +10 -6
  111. package/dist/types.d.ts +21 -5
  112. package/dist/update/UpdateService.d.ts +2 -2
  113. package/dist/update/UpdateService.js.map +1 -1
  114. package/package.json +12 -14
  115. package/dist/auth/BasicAuthProvider.d.ts +0 -39
  116. package/dist/auth/BasicAuthProvider.js +0 -106
  117. package/dist/auth/BasicAuthProvider.js.map +0 -1
  118. package/dist/push.d.ts +0 -20
  119. package/dist/push.js.map +0 -1
package/README.md CHANGED
@@ -17,30 +17,36 @@ npm install @bluestep-systems/b6p-core
17
17
 
18
18
  ## Usage
19
19
 
20
- Construct `B6PCore` with your platform's [`B6PProviders`](src/providers.ts) implementation, then call
21
- the command methods:
20
+ Construct `B6PCore` with your platform's [`B6PProviders`](src/providers.ts) implementation, then reach
21
+ the platform through its subsystem services:
22
22
 
23
23
  ```typescript
24
24
  import { B6PCore, type B6PProviders } from "@bluestep-systems/b6p-core";
25
25
 
26
26
  const providers: B6PProviders = {
27
- fs, // IFileSystem — read/write/list files
28
- persistence, // IPersistence — durable key/value (settings, sessions)
29
- prompt, // IPrompt — ask the user for input/credentials
30
- logger, // ILogger — diagnostic logging
31
- progress, // IProgress — long-running task reporting
27
+ fs, // FileSystem — read/write/list files
28
+ persistence, // Persistence — durable key/value (settings, sessions)
29
+ prompt, // Prompt — ask the user for input/credentials
30
+ logger, // Logger — diagnostic logging
31
+ progress, // Progress — long-running task reporting
32
32
  };
33
33
 
34
34
  const core = new B6PCore(providers);
35
35
 
36
- await core.pull({ formulaUrl: "https://org.bluestep.net/files/<id>/draft/", workspacePath });
37
- await core.push({ rootPath, snapshot: true, message: "Update script" });
38
- const audit = await core.audit({ filePath, workspacePath });
36
+ await core.script.pull({ formulaUrl: "https://org.bluestep.net/files/<id>/draft/", workspacePath });
37
+ await core.script.push({ rootPath, snapshot: true, message: "Update script" });
38
+ const audit = await core.script.audit({ filePath, workspacePath });
39
39
  ```
40
40
 
41
41
  ### Command surface
42
42
 
43
- `B6PCore` exposes the operations both front-ends drive:
43
+ `B6PCore` is a composition root, not a flat command bag. It owns the platform-facing singletons —
44
+ `auth`, `sessionManager`, `orgCache`, `scriptMetadataStore` — and exposes each area of
45
+ functionality as its own service. Script management is `core.script`; further subsystems are added
46
+ beside it rather than onto `B6PCore` itself.
47
+
48
+ `core.script` ([`ScriptService`](src/script/ScriptService.ts)) — everything that moves a script tree
49
+ between the local filesystem and the platform over WebDAV:
44
50
 
45
51
  | Method | Purpose |
46
52
  | --- | --- |
@@ -48,10 +54,19 @@ const audit = await core.audit({ filePath, workspacePath });
48
54
  | `pull` / `pullCurrent` | Download script files from a formula URL into a workspace |
49
55
  | `audit` / `auditPull` | Compare local vs. server; optionally pull differences |
50
56
  | `deploy` | Multi-target deploy driven by a config file |
57
+ | `getSetupUrl` | Resolve a pulled script's web-UI setup page |
58
+ | `deriveWorkspacePath` | Recover the workspace folder from a path inside a script root |
59
+ | `getFactory` | The `ScriptFactory` for entering the script tree from a bare path |
60
+
61
+ `core` itself — cross-cutting state that is not specific to any one subsystem:
62
+
63
+ | Method | Purpose |
64
+ | --- | --- |
51
65
  | `report` | Report cached metadata / org-cache state |
52
66
  | `updateCredentials` / `clearSessions` / `clearSettings` / `clearAll` | Auth & state management |
53
- | `getConfig` / `setConfig` / `getSetupUrl` | Configuration helpers |
67
+ | `getConfig` / `setConfig` | Configuration helpers |
54
68
  | `checkForUpdates` | GitHub-releases-based update check |
69
+ | `dispose` | Release the session cleanup timer and org-cache resources |
55
70
 
56
71
  See [`src/index.ts`](src/index.ts) for the full set of exported classes, provider interfaces, data
57
72
  utilities, constants, and types.
@@ -61,10 +76,11 @@ utilities, constants, and types.
61
76
  ```bash
62
77
  npm install
63
78
  npm run check-types # tsc --noEmit
64
- npm run lint # eslint
65
79
  npm run compile # tsc → dist/
66
80
  npm run watch # tsc --watch
67
81
  npm run format # prettier --write
82
+ npm run format-check # prettier --check — the style gate in CI
83
+ npm test # compile, then every spec listed in package.json's `test` script
68
84
  npm run clean # rm -rf dist
69
85
  ```
70
86
 
package/dist/B6PCore.d.ts CHANGED
@@ -1,18 +1,10 @@
1
- import { BasicAuthProvider } from "./auth/BasicAuthProvider";
2
1
  import { SessionManager } from "./session/SessionManager";
3
- import type { B6PProviders, IFileSystem, ILogger, IPersistence, IProgress, IPrompt } from "./providers";
2
+ import type { AuthProvider, B6PProviders } from "./providers";
3
+ import type { AuthParams } from "./types";
4
4
  import { ScriptMetaDataStore } from "./cache/ScriptMetaDataStore";
5
5
  import { OrgCache } from "./cache/OrgCache";
6
- import type { ScriptContext } from "./script/ScriptContext";
7
- import { ScriptFactory } from "./script/ScriptFactory";
6
+ import { ScriptService } from "./script/ScriptService";
8
7
  import { UpdateService } from "./update/UpdateService";
9
- /**
10
- * Result returned by the audit command.
11
- */
12
- export interface AuditResult {
13
- changedFiles: string[];
14
- baseUrl: string;
15
- }
16
8
  /**
17
9
  * Result returned by the report command.
18
10
  */
@@ -22,76 +14,54 @@ export interface ReportResult {
22
14
  details: string;
23
15
  }
24
16
  /**
25
- * Headless orchestrator for all B6P operations.
17
+ * Headless SDK entry point for the BlueStep platform.
26
18
  *
27
19
  * Consumers (VS Code extension, CLI, tests) construct this with their own
28
- * {@link B6PProviders} implementations, then call the command methods.
20
+ * {@link B6PProviders} implementations, then reach the platform through it.
21
+ *
22
+ * This class is a **composition root**: it owns the platform-facing singletons
23
+ * (auth, session, caches) and assembles the subsystem services that use them.
24
+ * Script management lives behind {@link B6PCore.script}, not on this class —
25
+ * `core.script.push(...)`, `core.script.pull(...)` — leaving room for further
26
+ * subsystems (forms, users, reporting) to sit beside it without turning this into
27
+ * a flat bag of every operation the platform supports.
28
+ *
29
+ * The five raw providers are **private on purpose**, and the reason is not
30
+ * stylistic. Re-publishing them bought a consumer nothing — it already holds the
31
+ * objects it passed in — while costing two things. First, a subsystem could then
32
+ * reach `core.persistence` instead of receiving a bundle, which is exactly the
33
+ * accretion {@link ScriptContext} was cleaned up to stop. Second, and worse, an
34
+ * earlier revision of this comment claimed the class "deliberately does not
35
+ * implement any of the interfaces it hands out" while `const ctx: ScriptContext =
36
+ * core` still type-checked: dropping the `implements` clause removed the
37
+ * declaration, not the structural conformance, because these fields supplied every
38
+ * member. TypeScript is structural — the same trap `CLAUDE.md` documents for
39
+ * `AuthParams`. Making them private is what makes the claim true instead of
40
+ * decorative. Do not widen them back to `readonly`.
29
41
  *
30
42
  * This class contains zero `vscode.*` imports — all platform-specific
31
43
  * behaviour is delegated to the providers.
44
+ * @lastreviewed null
32
45
  */
33
- export declare class B6PCore implements ScriptContext {
34
- readonly fs: IFileSystem;
35
- readonly persistence: IPersistence;
36
- readonly prompt: IPrompt;
37
- readonly logger: ILogger;
38
- readonly progress: IProgress;
39
- readonly auth: BasicAuthProvider;
46
+ export declare class B6PCore {
47
+ private readonly fs;
48
+ private readonly persistence;
49
+ private readonly prompt;
50
+ private readonly logger;
51
+ private readonly progress;
52
+ readonly auth: AuthProvider<AuthParams>;
40
53
  readonly sessionManager: SessionManager;
41
54
  readonly scriptMetadataStore: ScriptMetaDataStore;
42
55
  readonly orgCache: OrgCache;
43
56
  readonly updateService: UpdateService | null;
44
- readonly typescriptLibDirs?: readonly string[];
45
- private factory;
57
+ /**
58
+ * Script management: push, pull, audit, deploy, and setup-URL resolution.
59
+ * @lastreviewed null
60
+ */
61
+ readonly script: ScriptService;
46
62
  private readonly _isDebugMode;
47
63
  constructor(providers: B6PProviders);
48
- getScriptFactory(): ScriptFactory;
49
64
  isDebugMode(): boolean;
50
- /**
51
- * Create a ScriptUrlParser wired to this core's session and logger.
52
- */
53
- private createParser;
54
- /**
55
- * Derive the base WebDAV URL from a local file path by parsing the
56
- * downstairs path structure and looking up stored metadata.
57
- */
58
- private deriveBaseUrl;
59
- /**
60
- * Derive the workspace folder (parent of the org folder) from a file path
61
- * inside a script root. Returns null if the path can't be parsed.
62
- */
63
- deriveWorkspacePath(filePath: string): string | null;
64
- push(opts: {
65
- targetUrl?: string;
66
- rootPath: string;
67
- snapshot?: boolean;
68
- message?: string;
69
- }): Promise<void>;
70
- pushCurrent(opts: {
71
- filePath: string;
72
- snapshot?: boolean;
73
- message?: string;
74
- }): Promise<void>;
75
- pull(opts: {
76
- formulaUrl?: string;
77
- workspacePath: string;
78
- }): Promise<void>;
79
- pullCurrent(opts: {
80
- filePath: string;
81
- workspacePath: string;
82
- }): Promise<void>;
83
- audit(opts: {
84
- filePath: string;
85
- workspacePath: string;
86
- }): Promise<AuditResult | null>;
87
- private auditWithUrl;
88
- auditPull(opts: {
89
- filePath: string;
90
- workspacePath: string;
91
- }): Promise<void>;
92
- deploy(opts: {
93
- configPath: string;
94
- }): Promise<void>;
95
65
  updateCredentials(): Promise<void>;
96
66
  clearSessions(): Promise<void>;
97
67
  clearSettings(): Promise<void>;
@@ -100,18 +70,6 @@ export declare class B6PCore implements ScriptContext {
100
70
  checkForUpdates(): Promise<void>;
101
71
  setConfig(key: string, value: unknown): Promise<void>;
102
72
  getConfig<T>(key: string): Promise<T | undefined>;
103
- /**
104
- * Builds the web-UI setup URL for a locally-pulled script, resolving its
105
- * stored metadata (org, classid, seqnum) from the {@link ScriptMetaDataStore}
106
- * the same way `audit` and `push` do.
107
- * @param opts.filePath Absolute path to any file inside the pulled script root.
108
- * @returns The setup URL, or `null` if no metadata is stored for the script
109
- * (not yet pulled) or its script type has no known setup page.
110
- * @lastreviewed null
111
- */
112
- getSetupUrl(opts: {
113
- filePath: string;
114
- }): Promise<string | null>;
115
73
  /**
116
74
  * Dispose resources (session cleanup timer, etc.).
117
75
  */