sendscript 2.3.4 → 2.3.5
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/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +12 -2
- package/example/typescript/docs/functions/add.md +1 -1
- package/example/typescript/docs/functions/square.md +1 -1
- package/package.json +1 -1
- package/parse.mjs +4 -4
- package/references.mjs +1 -1
- package/schema.mjs +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v2.3.5](https://github.com/bas080/sendscript/compare/v2.3.4...v2.3.5)
|
|
8
|
+
|
|
9
|
+
- Have reference and parse reference same schema type [`0a05608`](https://github.com/bas080/sendscript/commit/0a0560828b78d297bfa5b12639a5e54774c089bd)
|
|
10
|
+
|
|
7
11
|
#### [v2.3.4](https://github.com/bas080/sendscript/compare/v2.3.3...v2.3.4)
|
|
8
12
|
|
|
13
|
+
> 14 April 2026
|
|
14
|
+
|
|
9
15
|
- Improve naming in JSDocs [`669a40e`](https://github.com/bas080/sendscript/commit/669a40e28a5c77963d855dd4e2122d0ba2c074cd)
|
|
10
16
|
|
|
11
17
|
#### [v2.3.3](https://github.com/bas080/sendscript/compare/v2.3.2...v2.3.3)
|
package/CONTRIBUTING.md
CHANGED
|
@@ -40,7 +40,7 @@ Generate the README from the mz file.
|
|
|
40
40
|
```bash bash
|
|
41
41
|
markatzea ./README.mz | tee ./README.md
|
|
42
42
|
|
|
43
|
-
npx documentation readme references.mjs stringify.mjs parse.mjs -s Reference --github --a public --markdown-toc false
|
|
43
|
+
npx documentation readme schema.mjs references.mjs stringify.mjs parse.mjs -s Reference --github --a public --markdown-toc false
|
|
44
44
|
|
|
45
45
|
npx markdown-toc --maxdepth 3 -i README.md
|
|
46
46
|
|
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ Write JS code that you can run on servers, browsers or other clients.
|
|
|
15
15
|
* [Parse](#parse)
|
|
16
16
|
* [parse](#parse)
|
|
17
17
|
* [References](#references)
|
|
18
|
+
* [Schema](#schema)
|
|
18
19
|
* [defaultLeafStringify](#defaultleafstringify)
|
|
19
20
|
* [Stringify](#stringify)
|
|
20
21
|
* [stringify](#stringify)
|
|
@@ -135,7 +136,7 @@ Returns **any** 
|
|
|
135
136
|
|
|
136
137
|
#### Parameters
|
|
137
138
|
|
|
138
|
-
* `
|
|
139
|
+
* `schema` **[Schema](#schema)** 
|
|
139
140
|
* `env` **Env** runtime environment for refs
|
|
140
141
|
* `leafParse` (optional, default `defaultLeafParse`)
|
|
141
142
|
|
|
@@ -162,7 +163,7 @@ Schema supports:
|
|
|
162
163
|
|
|
163
164
|
#### Parameters
|
|
164
165
|
|
|
165
|
-
* `schema` **[
|
|
166
|
+
* `schema` **[Schema](#schema)** 
|
|
166
167
|
* `parentPath` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** (optional, default `[]`)
|
|
167
168
|
|
|
168
169
|
<!---->
|
|
@@ -171,6 +172,15 @@ Schema supports:
|
|
|
171
172
|
|
|
172
173
|
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Nested instrumented API object
|
|
173
174
|
|
|
175
|
+
### Schema
|
|
176
|
+
|
|
177
|
+
A schema defines the structure of the runtime API tree.
|
|
178
|
+
|
|
179
|
+
* string → leaf node
|
|
180
|
+
* \[name, children] → namespace
|
|
181
|
+
|
|
182
|
+
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | \[[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)])>
|
|
183
|
+
|
|
174
184
|
### defaultLeafStringify
|
|
175
185
|
|
|
176
186
|
Default strict serializer for leaf values.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **add**(`a`, `b`): `number`
|
|
10
10
|
|
|
11
|
-
Defined in: [math.ts:1](https://github.com/bas080/sendscript/blob/
|
|
11
|
+
Defined in: [math.ts:1](https://github.com/bas080/sendscript/blob/0a0560828b78d297bfa5b12639a5e54774c089bd/example/typescript/math.ts#L1)
|
|
12
12
|
|
|
13
13
|
## Parameters
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **square**(`a`): `number`
|
|
10
10
|
|
|
11
|
-
Defined in: [math.ts:2](https://github.com/bas080/sendscript/blob/
|
|
11
|
+
Defined in: [math.ts:2](https://github.com/bas080/sendscript/blob/0a0560828b78d297bfa5b12639a5e54774c089bd/example/typescript/math.ts#L2)
|
|
12
12
|
|
|
13
13
|
## Parameters
|
|
14
14
|
|
package/package.json
CHANGED
package/parse.mjs
CHANGED
|
@@ -112,14 +112,14 @@ const defaultLeafParse = (text) => JSON.parse(text)
|
|
|
112
112
|
* - collects and executes async awaits
|
|
113
113
|
* - evaluates AST-like JSON programs
|
|
114
114
|
*
|
|
115
|
-
* @param {
|
|
115
|
+
* @param {Schema} schema
|
|
116
116
|
* @param {Env} env - runtime environment for refs
|
|
117
117
|
* @param {(text: string) => any} [leafParse=defaultLeafParse]
|
|
118
118
|
* @returns {parse}
|
|
119
119
|
* @public
|
|
120
120
|
*/
|
|
121
|
-
export default function Parse (
|
|
122
|
-
const
|
|
121
|
+
export default function Parse (schema, env, leafParse = defaultLeafParse) {
|
|
122
|
+
const flatSchema = flattenSchema(schema)
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Parses and executes a serialized program.
|
|
@@ -160,7 +160,7 @@ export default function Parse (schemaArg, env, leafParse = defaultLeafParse) {
|
|
|
160
160
|
if (operator === 'ref') {
|
|
161
161
|
const path = rest
|
|
162
162
|
let current = env
|
|
163
|
-
let schemaCurrent =
|
|
163
|
+
let schemaCurrent = flatSchema
|
|
164
164
|
|
|
165
165
|
for (const segment of path) {
|
|
166
166
|
if (schemaCurrent && Object.hasOwn(schemaCurrent, segment)) {
|
package/references.mjs
CHANGED
|
@@ -104,7 +104,7 @@ function instrument (path) {
|
|
|
104
104
|
* - string => leaf function node
|
|
105
105
|
* - [name, children] => namespace with nested schema
|
|
106
106
|
*
|
|
107
|
-
* @param {
|
|
107
|
+
* @param {Schema} schema
|
|
108
108
|
* @param {Array<string>} [parentPath=[]]
|
|
109
109
|
* @returns {Object} Nested instrumented API object
|
|
110
110
|
*
|