@bluestep-systems/b6p-core 0.3.1 → 0.5.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.
- package/README.md +29 -13
- package/dist/B6PCore.d.ts +38 -80
- package/dist/B6PCore.js +52 -360
- package/dist/B6PCore.js.map +1 -1
- package/dist/B6PUri.d.ts +147 -7
- package/dist/B6PUri.js +190 -12
- package/dist/B6PUri.js.map +1 -1
- package/dist/Err.js.map +1 -1
- package/dist/PlatformContext.d.ts +33 -0
- package/dist/PlatformContext.js +3 -0
- package/dist/PlatformContext.js.map +1 -0
- package/dist/auth/BearerAuthProvider.d.ts +64 -0
- package/dist/auth/BearerAuthProvider.js +148 -0
- package/dist/auth/BearerAuthProvider.js.map +1 -0
- package/dist/cache/OrgCache.d.ts +64 -7
- package/dist/cache/OrgCache.js +142 -23
- package/dist/cache/OrgCache.js.map +1 -1
- package/dist/cache/ScriptMetaDataStore.d.ts +52 -2
- package/dist/cache/ScriptMetaDataStore.js +80 -2
- package/dist/cache/ScriptMetaDataStore.js.map +1 -1
- package/dist/constants/ApiEndpoints.js.map +1 -1
- package/dist/constants/AuthTypes.d.ts +0 -1
- package/dist/constants/AuthTypes.js +0 -1
- package/dist/constants/AuthTypes.js.map +1 -1
- package/dist/constants/BlueHQ.js.map +1 -1
- package/dist/constants/CryptoAlgorithms.js.map +1 -1
- package/dist/constants/ExtensionConfig.js.map +1 -1
- package/dist/constants/FileExtensions.js.map +1 -1
- package/dist/constants/FolderNames.js.map +1 -1
- package/dist/constants/GitHubUrls.js.map +1 -1
- package/dist/constants/Http.js.map +1 -1
- package/dist/constants/MimeTypes.js.map +1 -1
- package/dist/constants/Numerical.js.map +1 -1
- package/dist/constants/OutputChannels.js.map +1 -1
- package/dist/constants/SettingsKeys.js.map +1 -1
- package/dist/constants/SpecialFiles.js.map +1 -1
- package/dist/constants/WebDAVElements.js.map +1 -1
- package/dist/data/DownstairsPathParser.js.map +1 -1
- package/dist/data/GlobMatcher.js.map +1 -1
- package/dist/data/IdUtility.d.ts +2 -2
- package/dist/data/IdUtility.js.map +1 -1
- package/dist/data/OrgWorker.js.map +1 -1
- package/dist/data/ScriptKey.js.map +1 -1
- package/dist/data/ScriptUrlParser.d.ts +4 -3
- package/dist/data/ScriptUrlParser.js +2 -1
- package/dist/data/ScriptUrlParser.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/network/HttpClient.js.map +1 -1
- package/dist/network/HttpClientProvider.js.map +1 -1
- package/dist/network/StatusCodes.js.map +1 -1
- package/dist/persistence/PersistablePseudoMap.d.ts +12 -7
- package/dist/persistence/PersistablePseudoMap.js +12 -5
- package/dist/persistence/PersistablePseudoMap.js.map +1 -1
- package/dist/persistence/PersistenceKeys.d.ts +0 -4
- package/dist/persistence/PersistenceKeys.js +0 -4
- package/dist/persistence/PersistenceKeys.js.map +1 -1
- package/dist/persistence/PrivatePersistanceMap.d.ts +4 -3
- package/dist/persistence/PrivatePersistanceMap.js +2 -1
- package/dist/persistence/PrivatePersistanceMap.js.map +1 -1
- package/dist/persistence/PseudoMap.js.map +1 -1
- package/dist/persistence/PublicPersistanceMap.d.ts +3 -3
- package/dist/persistence/PublicPersistanceMap.js +1 -1
- package/dist/persistence/PublicPersistanceMap.js.map +1 -1
- package/dist/persistence/Serializable.js.map +1 -1
- package/dist/persistence/SharedFilePersistence.d.ts +4 -3
- package/dist/persistence/SharedFilePersistence.js +129 -7
- package/dist/persistence/SharedFilePersistence.js.map +1 -1
- package/dist/persistence/TypedMap.js.map +1 -1
- package/dist/persistence/TypedPersistable.d.ts +5 -5
- package/dist/persistence/TypedPersistable.js +2 -2
- package/dist/persistence/TypedPersistable.js.map +1 -1
- package/dist/persistence/TypedPrivatePersistable.d.ts +3 -3
- package/dist/persistence/TypedPrivatePersistable.js +1 -1
- package/dist/persistence/TypedPrivatePersistable.js.map +1 -1
- package/dist/persistence/dirLockdown.js.map +1 -1
- package/dist/providers.d.ts +70 -13
- package/dist/script/ScriptContext.d.ts +17 -16
- package/dist/script/ScriptFactory.d.ts +23 -16
- package/dist/script/ScriptFactory.js +23 -44
- package/dist/script/ScriptFactory.js.map +1 -1
- package/dist/script/ScriptFile.d.ts +12 -0
- package/dist/script/ScriptFile.js +14 -1
- package/dist/script/ScriptFile.js.map +1 -1
- package/dist/script/ScriptFolder.d.ts +21 -0
- package/dist/script/ScriptFolder.js +28 -4
- package/dist/script/ScriptFolder.js.map +1 -1
- package/dist/script/ScriptNode.js.map +1 -1
- package/dist/script/ScriptRoot.js +10 -6
- package/dist/script/ScriptRoot.js.map +1 -1
- package/dist/script/ScriptService.d.ts +112 -0
- package/dist/script/ScriptService.js +411 -0
- package/dist/script/ScriptService.js.map +1 -0
- package/dist/script/ScriptTranspiler.js.map +1 -1
- package/dist/script/SnapshotHistoryRecorder.d.ts +14 -1
- package/dist/script/SnapshotHistoryRecorder.js +15 -10
- package/dist/script/SnapshotHistoryRecorder.js.map +1 -1
- package/dist/script/TsConfig.js.map +1 -1
- package/dist/script/TsLibResolver.js.map +1 -1
- package/dist/{push.d.ts → script/push.d.ts} +1 -3
- package/dist/{push.js → script/push.js} +10 -10
- package/dist/script/push.js.map +1 -0
- package/dist/session/SessionManager.d.ts +3 -2
- package/dist/session/SessionManager.js.map +1 -1
- package/dist/testing/MockFileSystem.d.ts +16 -3
- package/dist/testing/MockFileSystem.js +65 -42
- package/dist/testing/MockFileSystem.js.map +1 -1
- package/dist/testing/TestableFactory.d.ts +10 -6
- package/dist/types.d.ts +21 -5
- package/dist/update/UpdateService.d.ts +2 -2
- package/dist/update/UpdateService.js.map +1 -1
- package/package.json +12 -14
- package/dist/auth/BasicAuthProvider.d.ts +0 -39
- package/dist/auth/BasicAuthProvider.js +0 -106
- package/dist/auth/BasicAuthProvider.js.map +0 -1
- 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
|
|
21
|
-
the
|
|
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, //
|
|
28
|
-
persistence, //
|
|
29
|
-
prompt, //
|
|
30
|
-
logger, //
|
|
31
|
-
progress, //
|
|
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`
|
|
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`
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
34
|
-
readonly fs
|
|
35
|
-
readonly persistence
|
|
36
|
-
readonly prompt
|
|
37
|
-
readonly logger
|
|
38
|
-
readonly progress
|
|
39
|
-
readonly auth:
|
|
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
|
-
|
|
45
|
-
|
|
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
|
*/
|