@syncmatters/script-api 1.0.10 → 1.0.12
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.
|
@@ -24,9 +24,9 @@ AGENTS.md # CLI-generated agent guide (managed block + your notes belo
|
|
|
24
24
|
| `groups/**/group.config.json` | **No** | **No** |
|
|
25
25
|
| `types/**`, `.sm/`, `package.json`, `jsconfig.json` | **No** | **No** |
|
|
26
26
|
|
|
27
|
-
Sync and sync-group **configuration**
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
Sync and sync-group **configuration** is authored in `changes/*.sync-changes.json` and published
|
|
28
|
+
with `sm sync push` after a human reviews `sm sync draft`. Snapshots under `syncs/` and `groups/`
|
|
29
|
+
are **read-only context** — never hand-edit or `sm push` them. Schedules still start in the web UI.
|
|
30
30
|
|
|
31
31
|
Generated sync/group files include a marker:
|
|
32
32
|
|
|
@@ -30,8 +30,22 @@ Each file starts with:
|
|
|
30
30
|
|
|
31
31
|
- Do **not** hand-edit snapshots to change mappings, schedules, or wiring.
|
|
32
32
|
- Do **not** `sm push` snapshot paths — there is no push route for them today.
|
|
33
|
-
- Do **not** treat snapshots as the source of truth for writes
|
|
34
|
-
|
|
33
|
+
- Do **not** treat snapshots as the source of truth for writes. Author mapping changes in
|
|
34
|
+
`changes/*.sync-changes.json`, preview with `sm sync draft <file>`, then `sm sync push <file>`
|
|
35
|
+
only when the human has instructed it. Snapshots stay generated.
|
|
36
|
+
|
|
37
|
+
## Preview drafts (`sm sync draft`)
|
|
38
|
+
|
|
39
|
+
Preview writes a second JSON tree (not a pull snapshot):
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
syncs/<sync_uid>/sync.config.draft.json # existing sync, after the changeset
|
|
43
|
+
changes/<name>.draft.<handle>.json # created sync/group (`$` stripped)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`$sm.generated_by` is `"sm sync draft"`. These files are evaluation output — never a `sm push`
|
|
47
|
+
payload. `sm pull` never deletes `*.draft.json` (rename+`--force` relocates them with the uid).
|
|
48
|
+
A rerun of `sm sync draft <file>` replaces `changes/<name>.draft.*.json` for that changeset stem.
|
|
35
49
|
|
|
36
50
|
## Refresh
|
|
37
51
|
|
|
@@ -41,5 +55,5 @@ Each file starts with:
|
|
|
41
55
|
| `sm pull` | Scripts + snapshots (unless `--no-syncs`) |
|
|
42
56
|
| `sm pull sync --force` | Overwrite locally modified **generated** snapshots |
|
|
43
57
|
|
|
44
|
-
Missing `syncs:read` on the developer token: default pull warns and skips; `sm pull sync`
|
|
45
|
-
2 with mint-token guidance.
|
|
58
|
+
Missing `syncs:read` on the developer token: default pull warns and skips; `sm pull sync` and
|
|
59
|
+
`sm sync draft` exit 2 with mint-token guidance.
|
|
@@ -13,7 +13,8 @@ sm pull sync # optional: refresh sync/group snapshots only
|
|
|
13
13
|
|
|
14
14
|
- **Scripts only:** `sm push` uploads changed files under `files/` (and meta sidecars). It does
|
|
15
15
|
**not** upload `syncs/` or `groups/`.
|
|
16
|
-
- **Sync config changes:**
|
|
16
|
+
- **Sync config changes:** `changes/*.sync-changes.json` → `sm sync draft` → human review →
|
|
17
|
+
`sm sync push` (needs `syncs:write`). Agents push only on human instruction.
|
|
17
18
|
- **Reading snapshots:** use `syncs/` and `groups/` for context before editing the wired module
|
|
18
19
|
in `files/`.
|
|
19
20
|
|
|
@@ -30,7 +31,8 @@ Prefer tokens **without execute scopes** for day-to-day edit/push work:
|
|
|
30
31
|
| --- | --- |
|
|
31
32
|
| `scripts:read` | pull, diff incoming |
|
|
32
33
|
| `scripts:write` | push script files |
|
|
33
|
-
| `syncs:read` | `sm pull sync`, sync snapshots |
|
|
34
|
+
| `syncs:read` | `sm pull sync`, sync snapshots, `sm sync draft` |
|
|
35
|
+
| `syncs:write` | `sm sync push` / `applysyncops` (human-approved publish) |
|
|
34
36
|
| `connections:read` | `sm types`, connection resolution |
|
|
35
37
|
| `scripts:execute` | **Only when running** `sm test` / connector features |
|
|
36
38
|
| `syncs:execute` | Reserved; not needed for authoring |
|
|
@@ -48,7 +50,7 @@ If the CLI reports **403** with missing scope or "not available to developer tok
|
|
|
48
50
|
|
|
49
51
|
Examples:
|
|
50
52
|
|
|
51
|
-
- Missing `syncs:read` → cannot pull sync snapshots (`sm pull sync`).
|
|
53
|
+
- Missing `syncs:read` → cannot pull sync snapshots (`sm pull sync`) or preview a changeset (`sm sync draft`).
|
|
52
54
|
- Missing `scripts:execute` → cannot run `sm test` (expected if using a read/write-only token).
|
|
53
55
|
|
|
54
56
|
## Non-interactive runs
|
package/lib/context.d.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
|
+
import type { ConnectionMap } from "@syncmatters/script-api/connections/map";
|
|
2
|
+
import type { SyncGroupMap } from "@syncmatters/script-api/syncGroups/map";
|
|
1
3
|
import { Connection } from "./connection.js";
|
|
2
4
|
import { SyncGroup } from "./sync-group.js";
|
|
3
5
|
import { Logger } from "./logger.js";
|
|
4
6
|
import { FileProvider } from "./utilities/file-provider/file-provider.js";
|
|
7
|
+
/**
|
|
8
|
+
* When the org map is empty (no `sm types` overlay), keep a string index so
|
|
9
|
+
* runners and tests still type `ctx.connections[name]`. Once keys are merged
|
|
10
|
+
* onto ConnectionMap / SyncGroupMap, those uids become typed factories.
|
|
11
|
+
*/
|
|
12
|
+
export type ContextMapFactories<M, Fallback> = [keyof M] extends [never] ? {
|
|
13
|
+
[name: string]: () => Promise<Fallback>;
|
|
14
|
+
} : {
|
|
15
|
+
[P in keyof M]: () => Promise<M[P]>;
|
|
16
|
+
};
|
|
5
17
|
/** Context is passed to the script to provide access to system services such as logging, connections, state and environment information */
|
|
6
18
|
export interface Context {
|
|
7
19
|
log: Logger;
|
|
8
20
|
parameters: {
|
|
9
21
|
[name: string]: any;
|
|
10
22
|
};
|
|
11
|
-
connections:
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
syncGroups: {
|
|
15
|
-
[name: string]: () => Promise<SyncGroup>;
|
|
16
|
-
};
|
|
23
|
+
connections: ContextMapFactories<ConnectionMap, Connection>;
|
|
24
|
+
syncGroups: ContextMapFactories<SyncGroupMap, SyncGroup>;
|
|
17
25
|
state: {
|
|
18
26
|
get(): Promise<any>;
|
|
19
27
|
set(state: any): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncmatters/script-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "TypeScript type definitions for the SyncMatters script API (types only - scripts execute on the SyncMatters platform)",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -15,12 +15,20 @@
|
|
|
15
15
|
"./api": {
|
|
16
16
|
"types": "./api.d.ts",
|
|
17
17
|
"default": "./index.js"
|
|
18
|
+
},
|
|
19
|
+
"./connections/map": {
|
|
20
|
+
"types": "./connections/map.d.ts",
|
|
21
|
+
"default": "./index.js"
|
|
22
|
+
},
|
|
23
|
+
"./syncGroups/map": {
|
|
24
|
+
"types": "./syncGroups/map.d.ts",
|
|
25
|
+
"default": "./index.js"
|
|
18
26
|
}
|
|
19
27
|
},
|
|
20
28
|
"license": "MIT",
|
|
21
29
|
"author": "SyncMatters",
|
|
22
30
|
"homepage": "https://syncmatters.com",
|
|
23
|
-
"typesContentHash": "
|
|
31
|
+
"typesContentHash": "87bf322ba471ad760d94c31884ed28859fb460b28f3558f876ee88423eda1c92",
|
|
24
32
|
"dependencies": {
|
|
25
33
|
"@types/node": "*"
|
|
26
34
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Org sync-group uid → `SyncGroup`. Every key is the same runtime type;
|
|
3
|
+
* the map exists so `ctx.syncGroups.<uid>()` can complete.
|
|
4
|
+
*
|
|
5
|
+
* Empty in this package. `sm types` / the web editor merge keys via
|
|
6
|
+
* `declare module '@syncmatters/script-api/syncGroups/map'`.
|
|
7
|
+
*/
|
|
8
|
+
export interface SyncGroupMap {
|
|
9
|
+
}
|