@openclaw/slack 2026.8.1-beta.2 → 2026.8.1
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/dist/account-configured-sUohAxZr.js +33 -0
- package/dist/account-inspect-CN2hBsim.js +87 -0
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-CK4AVI2_.js → accounts-Dm_H77gH.js} +12 -11
- package/dist/{accounts.runtime-Cb7QwWBz.js → accounts.runtime-DRuEK6mL.js} +1 -1
- package/dist/{action-runtime-BkGe7ny_.js → action-runtime-044ldvNL.js} +80 -79
- package/dist/action-runtime.runtime-BL3KzX13.js +2 -0
- package/dist/{actions-BTDXwwE3.js → actions-BI7JkfVm.js} +273 -263
- package/dist/api.js +14 -14
- package/dist/{approval-handler.runtime-CJaNzAq2.js → approval-handler.runtime-DYv0UIZS.js} +53 -174
- package/dist/{channel-D_tovcUL.js → channel-1vIJOzPx.js} +134 -160
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-type-B9MSdoGN.js → channel-type-DlFSKeIZ.js} +3 -7
- package/dist/{channel.setup-Bch9dYmA.js → channel.setup-ofDi3_Pu.js} +34 -49
- package/dist/{config-schema-xto5jFIx.js → config-schema-BVIMyiDN.js} +42 -19
- package/dist/configured-state.js +34 -0
- package/dist/conversation-binding-route-DFVLUdYF.js +115 -0
- package/dist/{directory-config-CNBz8lJa.js → directory-config-DqfQ42OV.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-CFKUtW9E.js → directory-live-BPaNHjmP.js} +2 -2
- package/dist/{group-policy-c4RP9bjc.js → group-policy-BdwszjYn.js} +625 -773
- package/dist/{message-tool-api-BykQB4AU.js → message-tool-api-CJ0kjcg5.js} +23 -5
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-1nF1NtqT.js → monitor-Dq5Cmrvp.js} +3 -3
- package/dist/{outbound-adapter-S81tsswN.js → outbound-adapter-DYaI8ThX.js} +101 -66
- package/dist/{pipeline.runtime-BvYsM5JO.js → pipeline.runtime-Bd22U0ga.js} +494 -474
- package/dist/{policy-TapwbeaT.js → policy-CtQVbde1.js} +2 -1
- package/dist/{probe-HoEg_WxB.js → probe-0usmAb0i.js} +209 -22
- package/dist/{provider-CDNvBXUi.js → provider-CN_8hFv2.js} +296 -178
- package/dist/{relay-source-C9leF11u.js → relay-source-BNGpsdwV.js} +1 -1
- package/dist/{replies-CeOfv82I.js → replies-BSiRQOJ1.js} +48 -27
- package/dist/{resolve-channels-CNPrxaXY.js → resolve-channels-Czheznc8.js} +1 -1
- package/dist/{resolve-users-Dzomuwnr.js → resolve-users-BAOlNimr.js} +1 -1
- package/dist/runtime-api.js +11 -11
- package/dist/{scopes-cYXKkrRD.js → scopes-COSlmhnH.js} +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/{send-Nor0iBwY.js → send-DS9ICrBI.js} +88 -100
- package/dist/send-results-eeOu_HYm.js +23 -0
- package/dist/{send.runtime-BmgNe6S9.js → send.runtime-D_Bb6IuH.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CbX1-Knh.js → setup-surface-BGnd2pSe.js} +6 -6
- package/dist/{shared-zdT5AMp-.js → shared-D5B-5hBg.js} +35 -9
- package/dist/{slash-dispatch.runtime-Bnr9GR1S.js → slash-dispatch.runtime-CilDmI0c.js} +2 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/bolt/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/bolt/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/bolt/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/bolt/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/bolt/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/bolt/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/bolt/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/socket-mode/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/socket-mode/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/socket-mode/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/socket-mode/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/socket-mode/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/socket-mode/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/socket-mode/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/web-api/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/web-api/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/web-api/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/web-api/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +57 -7
- package/package.json +9 -9
- package/dist/account-configured-BwfXBo_F.js +0 -14
- package/dist/account-inspect-Drw2gAiN.js +0 -89
- package/dist/account-reply-mode-DrUXogvO.js +0 -14
- package/dist/action-runtime.runtime-D9I6uc0Q.js +0 -2
- package/dist/actions.runtime-DLFyUkvg.js +0 -2
- package/dist/block-text-YtiNkqmx.js +0 -79
- package/dist/runtime-api-Cj9nxBNv.js +0 -10
- package/node_modules/p-map/index.d.ts +0 -155
- package/node_modules/p-map/index.js +0 -285
- package/node_modules/p-map/license +0 -9
- package/node_modules/p-map/package.json +0 -57
- package/node_modules/p-map/readme.md +0 -190
- package/node_modules/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
- package/dist/{security-audit-DR097212.js → security-audit-B_yKr7MW.js} +1 -1
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
# p-map
|
|
2
|
-
|
|
3
|
-
> Map over promises concurrently
|
|
4
|
-
|
|
5
|
-
Useful when you need to run promise-returning & async functions multiple times with different inputs concurrently.
|
|
6
|
-
|
|
7
|
-
This is different from `Promise.all()` in that you can control the concurrency and also decide whether or not to stop iterating when there's an error.
|
|
8
|
-
|
|
9
|
-
## Install
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm install p-map
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
```js
|
|
18
|
-
import pMap from 'p-map';
|
|
19
|
-
import got from 'got';
|
|
20
|
-
|
|
21
|
-
const sites = [
|
|
22
|
-
getWebsiteFromUsername('sindresorhus'), //=> Promise
|
|
23
|
-
'https://avajs.dev',
|
|
24
|
-
'https://github.com'
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
const mapper = async site => {
|
|
28
|
-
const {requestUrl} = await got.head(site);
|
|
29
|
-
return requestUrl;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const result = await pMap(sites, mapper, {concurrency: 2});
|
|
33
|
-
|
|
34
|
-
console.log(result);
|
|
35
|
-
//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## API
|
|
39
|
-
|
|
40
|
-
### pMap(input, mapper, options?)
|
|
41
|
-
|
|
42
|
-
Returns a `Promise` that is fulfilled when all promises in `input` and the ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
|
|
43
|
-
|
|
44
|
-
### pMapIterable(input, mapper, options?)
|
|
45
|
-
|
|
46
|
-
Returns an async iterable that streams each return value from `mapper` in order.
|
|
47
|
-
|
|
48
|
-
```js
|
|
49
|
-
import {pMapIterable} from 'p-map';
|
|
50
|
-
|
|
51
|
-
// Multiple posts are fetched concurrently, with limited concurrency and backpressure
|
|
52
|
-
for await (const post of pMapIterable(postIds, getPostMetadata, {concurrency: 8})) {
|
|
53
|
-
console.log(post);
|
|
54
|
-
};
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
#### input
|
|
58
|
-
|
|
59
|
-
Type: `AsyncIterable<Promise<unknown> | unknown> | Iterable<Promise<unknown> | unknown>`
|
|
60
|
-
|
|
61
|
-
Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item.
|
|
62
|
-
|
|
63
|
-
Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.
|
|
64
|
-
|
|
65
|
-
#### mapper(element, index)
|
|
66
|
-
|
|
67
|
-
Type: `Function`
|
|
68
|
-
|
|
69
|
-
Expected to return a `Promise` or value.
|
|
70
|
-
|
|
71
|
-
#### options
|
|
72
|
-
|
|
73
|
-
Type: `object`
|
|
74
|
-
|
|
75
|
-
##### concurrency
|
|
76
|
-
|
|
77
|
-
Type: `number` *(Integer)*\
|
|
78
|
-
Default: `Infinity`\
|
|
79
|
-
Minimum: `1`
|
|
80
|
-
|
|
81
|
-
Number of concurrently pending promises returned by `mapper`.
|
|
82
|
-
|
|
83
|
-
##### backpressure
|
|
84
|
-
|
|
85
|
-
**Only for `pMapIterable`**
|
|
86
|
-
|
|
87
|
-
Type: `number` *(Integer)*\
|
|
88
|
-
Default: `options.concurrency`\
|
|
89
|
-
Minimum: `options.concurrency`
|
|
90
|
-
|
|
91
|
-
Maximum number of promises returned by `mapper` that have resolved but not yet collected by the consumer of the async iterable. Calls to `mapper` will be limited so that there is never too much backpressure.
|
|
92
|
-
|
|
93
|
-
Useful whenever you are consuming the iterable slower than what the mapper function can produce concurrently. For example, to avoid making an overwhelming number of HTTP requests if you are saving each of the results to a database.
|
|
94
|
-
|
|
95
|
-
##### stopOnError
|
|
96
|
-
|
|
97
|
-
**Only for `pMap`**
|
|
98
|
-
|
|
99
|
-
Type: `boolean`\
|
|
100
|
-
Default: `true`
|
|
101
|
-
|
|
102
|
-
When `true`, the first mapper rejection will be rejected back to the consumer.
|
|
103
|
-
|
|
104
|
-
When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) containing all the errors from the rejected promises.
|
|
105
|
-
|
|
106
|
-
Caveat: When `true`, any already-started async mappers will continue to run until they resolve or reject. In the case of infinite concurrency with sync iterables, *all* mappers are invoked on startup and will continue after the first rejection. Use the `signal` option for abort control.
|
|
107
|
-
|
|
108
|
-
##### signal
|
|
109
|
-
|
|
110
|
-
**Only for `pMap`**
|
|
111
|
-
|
|
112
|
-
Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
|
|
113
|
-
|
|
114
|
-
You can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
115
|
-
|
|
116
|
-
```js
|
|
117
|
-
import pMap from 'p-map';
|
|
118
|
-
import delay from 'delay';
|
|
119
|
-
|
|
120
|
-
const abortController = new AbortController();
|
|
121
|
-
|
|
122
|
-
setTimeout(() => {
|
|
123
|
-
abortController.abort();
|
|
124
|
-
}, 500);
|
|
125
|
-
|
|
126
|
-
const mapper = async value => value;
|
|
127
|
-
|
|
128
|
-
await pMap([delay(1000), delay(1000)], mapper, {signal: abortController.signal});
|
|
129
|
-
// Throws AbortError (DOMException) after 500 ms.
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### pMapSkip
|
|
133
|
-
|
|
134
|
-
Return this value from a `mapper` function to skip including the value in the returned array.
|
|
135
|
-
|
|
136
|
-
```js
|
|
137
|
-
import pMap, {pMapSkip} from 'p-map';
|
|
138
|
-
import got from 'got';
|
|
139
|
-
|
|
140
|
-
const sites = [
|
|
141
|
-
getWebsiteFromUsername('sindresorhus'), //=> Promise
|
|
142
|
-
'https://avajs.dev',
|
|
143
|
-
'https://example.invalid',
|
|
144
|
-
'https://github.com'
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
const mapper = async site => {
|
|
148
|
-
try {
|
|
149
|
-
const {requestUrl} = await got.head(site);
|
|
150
|
-
return requestUrl;
|
|
151
|
-
} catch {
|
|
152
|
-
return pMapSkip;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const result = await pMap(sites, mapper, {concurrency: 2});
|
|
157
|
-
|
|
158
|
-
console.log(result);
|
|
159
|
-
//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## Recipes
|
|
163
|
-
|
|
164
|
-
### Rate limiting
|
|
165
|
-
|
|
166
|
-
This package controls how many mapper promises run concurrently. To limit how often the mapper starts, compose it with a rate limiter like [`p-throttle`](https://github.com/sindresorhus/p-throttle):
|
|
167
|
-
|
|
168
|
-
```js
|
|
169
|
-
import pThrottle from 'p-throttle';
|
|
170
|
-
import pMap from 'p-map';
|
|
171
|
-
|
|
172
|
-
const throttle = pThrottle({
|
|
173
|
-
limit: 1,
|
|
174
|
-
interval: 1000,
|
|
175
|
-
strict: true,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
const result = await pMap(input, throttle(mapper), {concurrency: 2});
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
For more advanced scheduling, use [`p-queue`](https://github.com/sindresorhus/p-queue).
|
|
182
|
-
|
|
183
|
-
## Related
|
|
184
|
-
|
|
185
|
-
- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
|
|
186
|
-
- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
|
|
187
|
-
- [p-times](https://github.com/sindresorhus/p-times) - Run promise-returning & async functions a specific number of times concurrently
|
|
188
|
-
- [p-props](https://github.com/sindresorhus/p-props) - Like `Promise.all()` but for `Map` and `Object`
|
|
189
|
-
- [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially
|
|
190
|
-
- [More…](https://github.com/sindresorhus/promise-fun)
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { Unreachable } from '../system/unreachable/index.mjs';
|
|
2
|
-
import * as Puny from './_puny.mjs';
|
|
3
|
-
// ------------------------------------------------------------------
|
|
4
|
-
// Unicode General Category Helper (RFC 5892)
|
|
5
|
-
// ------------------------------------------------------------------
|
|
6
|
-
function IsNonspacingMark(cp) {
|
|
7
|
-
return /\p{Mn}/u.test(String.fromCodePoint(cp));
|
|
8
|
-
}
|
|
9
|
-
function IsSpacingCombiningMark(cp) {
|
|
10
|
-
return /\p{Mc}/u.test(String.fromCodePoint(cp));
|
|
11
|
-
}
|
|
12
|
-
function IsEnclosingMark(cp) {
|
|
13
|
-
return /\p{Me}/u.test(String.fromCodePoint(cp));
|
|
14
|
-
}
|
|
15
|
-
function IsCombiningMark(cp) {
|
|
16
|
-
return IsNonspacingMark(cp) || IsSpacingCombiningMark(cp) || IsEnclosingMark(cp);
|
|
17
|
-
}
|
|
18
|
-
// ------------------------------------------------------------------
|
|
19
|
-
// RFC 5892 §2.6 DISALLOWED exceptions
|
|
20
|
-
//
|
|
21
|
-
// https://tools.ietf.org/html/rfc5892#section-2.6
|
|
22
|
-
// ------------------------------------------------------------------
|
|
23
|
-
const RFC5892_DISALLOWED = new Set([
|
|
24
|
-
0x0640, // ARABIC TATWEEL
|
|
25
|
-
0x07fa, // NKO LAJANYALAN
|
|
26
|
-
0x302e, // HANGUL SINGLE DOT TONE MARK
|
|
27
|
-
0x302f, // HANGUL DOUBLE DOT TONE MARK
|
|
28
|
-
0x3031, // VERTICAL KANA REPEAT MARK
|
|
29
|
-
0x3032, // VERTICAL KANA REPEAT WITH VOICED ITERATION MARK
|
|
30
|
-
0x3033, // VERTICAL KANA REPEAT MARK UPPER HALF
|
|
31
|
-
0x3034, // VERTICAL KANA REPEAT WITH VOICED ITERATION MARK UPPER HALF
|
|
32
|
-
0x3035, // VERTICAL KANA REPEAT MARK LOWER HALF
|
|
33
|
-
0x303b // VERTICAL IDEOGRAPHIC ITERATION MARK
|
|
34
|
-
]);
|
|
35
|
-
// ------------------------------------------------------------------
|
|
36
|
-
// A set of Virama (halant) code points used to validate CONTEXTJ
|
|
37
|
-
// rules (RFC 5892 Appendix A.1). These characters allow a subsequent
|
|
38
|
-
// Zero Width Non-Joiner (U+200C) or Zero Width Joiner (U+200D) to
|
|
39
|
-
// be valid in a label.
|
|
40
|
-
// ------------------------------------------------------------------
|
|
41
|
-
const VIRAMA_CPS = new Set([
|
|
42
|
-
0x094d,
|
|
43
|
-
0x09cd,
|
|
44
|
-
0x0a4d,
|
|
45
|
-
0x0acd,
|
|
46
|
-
0x0b4d,
|
|
47
|
-
0x0bcd,
|
|
48
|
-
0x0c4d,
|
|
49
|
-
0x0ccd,
|
|
50
|
-
0x0d3b,
|
|
51
|
-
0x0d3c,
|
|
52
|
-
0x0d4d,
|
|
53
|
-
0x0dca,
|
|
54
|
-
0x1b44,
|
|
55
|
-
0x1baa,
|
|
56
|
-
0x1bab,
|
|
57
|
-
0xa9c0,
|
|
58
|
-
0x11046,
|
|
59
|
-
0x1107f,
|
|
60
|
-
0x110b9,
|
|
61
|
-
0x11133,
|
|
62
|
-
0x11134,
|
|
63
|
-
0x111c0,
|
|
64
|
-
0x11235,
|
|
65
|
-
0x1134d,
|
|
66
|
-
0x11442,
|
|
67
|
-
0x114c2,
|
|
68
|
-
0x115bf,
|
|
69
|
-
0x1163f,
|
|
70
|
-
0x116b6,
|
|
71
|
-
0x11c3f,
|
|
72
|
-
0x11d44,
|
|
73
|
-
0x11d45
|
|
74
|
-
]);
|
|
75
|
-
// ------------------------------------------------------------------
|
|
76
|
-
// Guards for CONTEXTO rules (RFC 5892 Appendix A)
|
|
77
|
-
// ------------------------------------------------------------------
|
|
78
|
-
function IsGreek(cp) {
|
|
79
|
-
return /\p{Script=Greek}/u.test(String.fromCodePoint(cp));
|
|
80
|
-
}
|
|
81
|
-
function IsHebrew(cp) {
|
|
82
|
-
return /\p{Script=Hebrew}/u.test(String.fromCodePoint(cp));
|
|
83
|
-
}
|
|
84
|
-
function IsHiragana(cp) {
|
|
85
|
-
return /\p{Script=Hiragana}/u.test(String.fromCodePoint(cp));
|
|
86
|
-
}
|
|
87
|
-
function IsKatakana(cp) {
|
|
88
|
-
return /\p{Script=Katakana}/u.test(String.fromCodePoint(cp));
|
|
89
|
-
}
|
|
90
|
-
function IsHan(cp) {
|
|
91
|
-
return /\p{Script=Han}/u.test(String.fromCodePoint(cp));
|
|
92
|
-
}
|
|
93
|
-
function IsArabicIndicDigit(cp) {
|
|
94
|
-
return cp >= 0x0660 && cp <= 0x0669;
|
|
95
|
-
}
|
|
96
|
-
function IsExtendedArabicIndicDigit(cp) {
|
|
97
|
-
return cp >= 0x06f0 && cp <= 0x06f9;
|
|
98
|
-
}
|
|
99
|
-
function IsVirama(cp) {
|
|
100
|
-
return VIRAMA_CPS.has(cp);
|
|
101
|
-
}
|
|
102
|
-
// ------------------------------------------------------------------
|
|
103
|
-
// IsUnicodeLabel
|
|
104
|
-
// ------------------------------------------------------------------
|
|
105
|
-
function IsUnicodeLabel(value) {
|
|
106
|
-
// deno-coverage-ignore-start - unable to reach via format guards
|
|
107
|
-
if (value.length === 0)
|
|
108
|
-
return Unreachable(); // false
|
|
109
|
-
// deno-coverage-ignore-stop
|
|
110
|
-
// Use spread to handle surrogate pairs and provide O(1) neighbor access
|
|
111
|
-
const cps = [...value].map((c) => c.codePointAt(0));
|
|
112
|
-
const len = cps.length;
|
|
113
|
-
// RFC 5891 §4.2.3.2: Hyphen rules
|
|
114
|
-
if (cps[0] === 0x2d || cps[len - 1] === 0x2d)
|
|
115
|
-
return false;
|
|
116
|
-
if (len >= 4 && cps[2] === 0x2d && cps[3] === 0x2d)
|
|
117
|
-
return false;
|
|
118
|
-
// RFC 5891 §4.2.3.2 - Must not begin with a combining mark
|
|
119
|
-
if (IsCombiningMark(cps[0]))
|
|
120
|
-
return false;
|
|
121
|
-
let hasJapanese = false;
|
|
122
|
-
let hasArabicIndic = false;
|
|
123
|
-
let hasExtendedArabicIndic = false;
|
|
124
|
-
for (let i = 0; i < len; i++) {
|
|
125
|
-
const cp = cps[i];
|
|
126
|
-
// 1. DISALLOWED exceptions
|
|
127
|
-
if (RFC5892_DISALLOWED.has(cp))
|
|
128
|
-
return false;
|
|
129
|
-
// 2. Collect Flags
|
|
130
|
-
if (IsHiragana(cp) || IsKatakana(cp) || IsHan(cp))
|
|
131
|
-
hasJapanese = true;
|
|
132
|
-
if (IsArabicIndicDigit(cp))
|
|
133
|
-
hasArabicIndic = true;
|
|
134
|
-
if (IsExtendedArabicIndicDigit(cp))
|
|
135
|
-
hasExtendedArabicIndic = true;
|
|
136
|
-
// 3. CONTEXTO / CONTEXTJ Neighbor Rules
|
|
137
|
-
const prev = cps[i - 1], next = cps[i + 1];
|
|
138
|
-
switch (cp) {
|
|
139
|
-
case 0x00b7:
|
|
140
|
-
if (prev !== 0x006c || next !== 0x006c)
|
|
141
|
-
return false;
|
|
142
|
-
break; // MIDDLE DOT (Catalan)
|
|
143
|
-
case 0x0375:
|
|
144
|
-
if (next === undefined || !IsGreek(next))
|
|
145
|
-
return false;
|
|
146
|
-
break; // Greek KERAIA
|
|
147
|
-
case 0x05f3:
|
|
148
|
-
case 0x05f4:
|
|
149
|
-
if (prev === undefined || !IsHebrew(prev))
|
|
150
|
-
return false;
|
|
151
|
-
break; // Hebrew GERESH
|
|
152
|
-
case 0x200c: // ZWNJ - RFC 5892 Appendix A.1
|
|
153
|
-
// Note: Full validation requires a Unicode joining type table. We reject
|
|
154
|
-
// only when preceded by ASCII (U+0000-U+007F), which can never satisfy
|
|
155
|
-
// the Virama or cursive-joining rules.
|
|
156
|
-
if (prev === undefined || (prev < 0x0080 && !IsVirama(prev)))
|
|
157
|
-
return false;
|
|
158
|
-
break;
|
|
159
|
-
case 0x200d: // ZWJ - RFC 5892 Appendix A.2
|
|
160
|
-
if (prev === undefined || !IsVirama(prev))
|
|
161
|
-
return false;
|
|
162
|
-
break;
|
|
163
|
-
case 0x30fb: /* Checked at end via hasJapanese */
|
|
164
|
-
break; // KATAKANA MIDDLE DOT
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// 4. Global Context Validations (Post-loop)
|
|
168
|
-
// RFC 5892 Appendix A.7 - Katakana Middle Dot requirement
|
|
169
|
-
if (value.includes('\u30fb') && !hasJapanese)
|
|
170
|
-
return false;
|
|
171
|
-
// RFC 5892 Appendix A.8/A.9 - Mixing Arabic Digits
|
|
172
|
-
if (hasArabicIndic && hasExtendedArabicIndic)
|
|
173
|
-
return false;
|
|
174
|
-
return true;
|
|
175
|
-
}
|
|
176
|
-
// ------------------------------------------------------------------
|
|
177
|
-
// IsAsciiLabel
|
|
178
|
-
// ------------------------------------------------------------------
|
|
179
|
-
function IsAsciiLabel(value) {
|
|
180
|
-
// Must not start or end with a hyphen
|
|
181
|
-
if (value.charCodeAt(0) === 45 || value.charCodeAt(value.length - 1) === 45)
|
|
182
|
-
return false;
|
|
183
|
-
// RFC 5891 §4.2.3.1 : "--" at positions 3-4 is reserved for A-labels only
|
|
184
|
-
if (value.length >= 4 && value.charCodeAt(2) === 45 && value.charCodeAt(3) === 45)
|
|
185
|
-
return false;
|
|
186
|
-
// All characters must be alphanumeric or hyphen
|
|
187
|
-
for (let i = 0; i < value.length; i++) {
|
|
188
|
-
const ch = value.charCodeAt(i);
|
|
189
|
-
if (!((ch >= 97 && ch <= 122) || // a-z
|
|
190
|
-
(ch >= 65 && ch <= 90) || // A-Z
|
|
191
|
-
(ch >= 48 && ch <= 57) || // 0-9
|
|
192
|
-
ch === 45 // '-'
|
|
193
|
-
))
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
// ------------------------------------------------------------------
|
|
199
|
-
// IsPunyLabel
|
|
200
|
-
// ------------------------------------------------------------------
|
|
201
|
-
function IsPuny(value) {
|
|
202
|
-
return value.toLowerCase().startsWith('xn--');
|
|
203
|
-
}
|
|
204
|
-
function IsPunyLabel(value) {
|
|
205
|
-
try {
|
|
206
|
-
const payload = value.slice(4).toLowerCase();
|
|
207
|
-
// 1. Structural Validation (RFC 3492 syntax)
|
|
208
|
-
//
|
|
209
|
-
// If the payload contains a hyphen, it MUST be a delimiter separating basic
|
|
210
|
-
// ASCII characters from the variable-length integers. A payload consisting
|
|
211
|
-
// of ONLY a hyphen or starting with multiple hyphens without basic ASCII
|
|
212
|
-
// characters (like "-9uc") is fundamentally malformed.
|
|
213
|
-
//
|
|
214
|
-
const lastHyphen = payload.lastIndexOf('-');
|
|
215
|
-
if (lastHyphen === 0) {
|
|
216
|
-
// Catches "-9uc" right here because the delimiter is at index 0, meaning 0
|
|
217
|
-
// basic ASCII characters preceded it, which is non-canonical.
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
// 2. Decode the payload
|
|
221
|
-
const decoded = Puny.Decode(payload);
|
|
222
|
-
if (!decoded)
|
|
223
|
-
return false;
|
|
224
|
-
// 3. Validate the output rules against RFC 5892
|
|
225
|
-
return IsUnicodeLabel(decoded);
|
|
226
|
-
}
|
|
227
|
-
catch {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
// ------------------------------------------------------------------
|
|
232
|
-
// IsIdnLabel
|
|
233
|
-
// ------------------------------------------------------------------
|
|
234
|
-
export function IsIdnLabel(value) {
|
|
235
|
-
if (value.length === 0 || value.length > 63)
|
|
236
|
-
return false;
|
|
237
|
-
return IsPuny(value) ? IsPunyLabel(value) : IsUnicodeLabel(value);
|
|
238
|
-
}
|
|
239
|
-
// ------------------------------------------------------------------
|
|
240
|
-
// IsLabel
|
|
241
|
-
// ------------------------------------------------------------------
|
|
242
|
-
export function IsLabel(value) {
|
|
243
|
-
if (value.length === 0 || value.length > 63)
|
|
244
|
-
return false;
|
|
245
|
-
return IsPuny(value) ? IsPunyLabel(value) : IsAsciiLabel(value);
|
|
246
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function Decode(value: string): string;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Unreachable } from '../system/unreachable/index.mjs';
|
|
2
|
-
// ------------------------------------------------------------------
|
|
3
|
-
// PunyCode (RFC 3492)
|
|
4
|
-
// ------------------------------------------------------------------
|
|
5
|
-
const PUNYCODE_BASE = 36;
|
|
6
|
-
const PUNYCODE_TMIN = 1;
|
|
7
|
-
const PUNYCODE_TMAX = 26;
|
|
8
|
-
const PUNYCODE_SKEW = 38;
|
|
9
|
-
const PUNYCODE_DAMP = 700;
|
|
10
|
-
const PUNYCODE_INITIAL_BIAS = 72;
|
|
11
|
-
const PUNYCODE_INITIAL_N = 128;
|
|
12
|
-
// ------------------------------------------------------------------
|
|
13
|
-
// Adapt
|
|
14
|
-
// ------------------------------------------------------------------
|
|
15
|
-
function Adapt(delta, numPoints, firstTime) {
|
|
16
|
-
delta = firstTime ? Math.floor(delta / PUNYCODE_DAMP) : delta >> 1;
|
|
17
|
-
delta += Math.floor(delta / numPoints);
|
|
18
|
-
let k = 0;
|
|
19
|
-
while (delta > (((PUNYCODE_BASE - PUNYCODE_TMIN) * PUNYCODE_TMAX) >> 1)) {
|
|
20
|
-
delta = Math.floor(delta / (PUNYCODE_BASE - PUNYCODE_TMIN));
|
|
21
|
-
k += PUNYCODE_BASE;
|
|
22
|
-
}
|
|
23
|
-
return k + Math.floor(((PUNYCODE_BASE - PUNYCODE_TMIN + 1) * delta) / (delta + PUNYCODE_SKEW));
|
|
24
|
-
}
|
|
25
|
-
// ------------------------------------------------------------------
|
|
26
|
-
// Decode
|
|
27
|
-
// ------------------------------------------------------------------
|
|
28
|
-
export function Decode(value) {
|
|
29
|
-
const output = [];
|
|
30
|
-
let n = PUNYCODE_INITIAL_N;
|
|
31
|
-
let i = 0;
|
|
32
|
-
let bias = PUNYCODE_INITIAL_BIAS;
|
|
33
|
-
const delimIdx = value.lastIndexOf('-');
|
|
34
|
-
if (delimIdx > 0) {
|
|
35
|
-
for (let j = 0; j < delimIdx; j++) {
|
|
36
|
-
const cp = value.charCodeAt(j);
|
|
37
|
-
if (cp >= 128)
|
|
38
|
-
throw new Error('Invalid punycode: non-basic before delimiter');
|
|
39
|
-
output.push(cp);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
let inIdx = delimIdx < 0 ? 0 : delimIdx + 1;
|
|
43
|
-
while (inIdx < value.length) {
|
|
44
|
-
const oldi = i;
|
|
45
|
-
let w = 1;
|
|
46
|
-
let k = PUNYCODE_BASE;
|
|
47
|
-
while (true) {
|
|
48
|
-
if (inIdx >= value.length)
|
|
49
|
-
throw new Error('Invalid punycode: unexpected end of input');
|
|
50
|
-
const ch = value.charCodeAt(inIdx++);
|
|
51
|
-
let digit;
|
|
52
|
-
if (ch >= 0x61 && ch <= 0x7a)
|
|
53
|
-
digit = ch - 0x61; // a-z => 0-25
|
|
54
|
-
else if (ch >= 0x30 && ch <= 0x39)
|
|
55
|
-
digit = ch - 0x30 + 26; // 0-9 => 26-35
|
|
56
|
-
// deno-coverage-ignore-start - _idna.ts maps input to lowercase, so we can't reach here
|
|
57
|
-
else if (ch >= 0x41 && ch <= 0x5a)
|
|
58
|
-
Unreachable(); // digit = ch - 0x41 // A-Z => 0-25
|
|
59
|
-
// deno-coverage-ignore-stop
|
|
60
|
-
else
|
|
61
|
-
throw new Error('Invalid punycode: bad digit character');
|
|
62
|
-
i += digit * w;
|
|
63
|
-
const t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;
|
|
64
|
-
if (digit < t)
|
|
65
|
-
break;
|
|
66
|
-
w *= PUNYCODE_BASE - t;
|
|
67
|
-
k += PUNYCODE_BASE;
|
|
68
|
-
}
|
|
69
|
-
const outLen = output.length + 1;
|
|
70
|
-
bias = Adapt(i - oldi, outLen, oldi === 0);
|
|
71
|
-
n += Math.floor(i / outLen);
|
|
72
|
-
i %= outLen;
|
|
73
|
-
output.splice(i, 0, n);
|
|
74
|
-
i++;
|
|
75
|
-
}
|
|
76
|
-
return globalThis.String.fromCodePoint(...output);
|
|
77
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as Schema from '../types/index.mjs';
|
|
2
|
-
export declare function Ref(schema: Schema.XSchemaObject, ref: string): Schema.XSchema | undefined;
|
|
3
|
-
export declare function DynamicRef(root: Schema.XSchemaObject, base: Schema.XSchemaObject, dynamicRef: Schema.XDynamicRef, dynamicAnchors: Schema.XDynamicAnchor[]): Schema.XSchema | undefined;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// deno-fmt-ignore-file
|
|
2
|
-
import { Guard } from '../../guard/index.mjs';
|
|
3
|
-
import { Pointer } from '../pointer/index.mjs';
|
|
4
|
-
import * as Schema from '../types/index.mjs';
|
|
5
|
-
// ------------------------------------------------------------------
|
|
6
|
-
// Match: Id
|
|
7
|
-
// ------------------------------------------------------------------
|
|
8
|
-
function MatchId(schema, base, ref) {
|
|
9
|
-
if (schema.$id === ref.hash)
|
|
10
|
-
return schema;
|
|
11
|
-
const absoluteId = new URL(schema.$id, base.href);
|
|
12
|
-
const absoluteRef = new URL(ref.href, base.href);
|
|
13
|
-
if (Guard.IsEqual(absoluteId.pathname, absoluteRef.pathname)) {
|
|
14
|
-
return ref.hash.startsWith('#') ? MatchHash(schema, base, ref) : schema;
|
|
15
|
-
}
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
// ------------------------------------------------------------------
|
|
19
|
-
// Match: Anchor
|
|
20
|
-
// ------------------------------------------------------------------
|
|
21
|
-
function MatchAnchor(schema, base, ref) {
|
|
22
|
-
const absoluteAnchor = new URL(`#${schema.$anchor}`, base.href);
|
|
23
|
-
const absoluteRef = new URL(ref.href, base.href);
|
|
24
|
-
return Guard.IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : undefined;
|
|
25
|
-
}
|
|
26
|
-
// ------------------------------------------------------------------
|
|
27
|
-
// Match: DynamicAnchor
|
|
28
|
-
// ------------------------------------------------------------------
|
|
29
|
-
function MatchDynamicAnchor(schema, base, ref) {
|
|
30
|
-
const absoluteAnchor = new URL(`#${schema.$dynamicAnchor}`, base.href);
|
|
31
|
-
const absoluteRef = new URL(ref.href, base.href);
|
|
32
|
-
return Guard.IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : undefined;
|
|
33
|
-
}
|
|
34
|
-
// ------------------------------------------------------------------
|
|
35
|
-
// Match: Hash
|
|
36
|
-
//
|
|
37
|
-
// Resolves JSON Pointer fragments only. Plain anchor-style fragments
|
|
38
|
-
// (no leading '/') are handled exclusively by MatchAnchor and
|
|
39
|
-
// MatchDynamicAnchor to prevent accidentally resolving an anchor name
|
|
40
|
-
// as a pointer into the schema tree.
|
|
41
|
-
//
|
|
42
|
-
// ------------------------------------------------------------------
|
|
43
|
-
function MatchHash(schema, _base, ref) {
|
|
44
|
-
if (ref.href.endsWith('#'))
|
|
45
|
-
return schema;
|
|
46
|
-
if (!ref.hash.startsWith('#'))
|
|
47
|
-
return undefined;
|
|
48
|
-
const fragment = decodeURIComponent(ref.hash.slice(1));
|
|
49
|
-
if (!fragment.startsWith('/'))
|
|
50
|
-
return undefined;
|
|
51
|
-
return Pointer.Get(schema, fragment);
|
|
52
|
-
}
|
|
53
|
-
// ------------------------------------------------------------------
|
|
54
|
-
// Match
|
|
55
|
-
// ------------------------------------------------------------------
|
|
56
|
-
function Match(schema, base, ref) {
|
|
57
|
-
if (Schema.IsId(schema)) {
|
|
58
|
-
const result = MatchId(schema, base, ref);
|
|
59
|
-
if (!Guard.IsUndefined(result))
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
if (Schema.IsAnchor(schema)) {
|
|
63
|
-
const result = MatchAnchor(schema, base, ref);
|
|
64
|
-
if (!Guard.IsUndefined(result))
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
if (Schema.IsDynamicAnchor(schema)) {
|
|
68
|
-
const result = MatchDynamicAnchor(schema, base, ref);
|
|
69
|
-
if (!Guard.IsUndefined(result))
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
return MatchHash(schema, base, ref);
|
|
73
|
-
}
|
|
74
|
-
// ------------------------------------------------------------------
|
|
75
|
-
// FromArray
|
|
76
|
-
// ------------------------------------------------------------------
|
|
77
|
-
function FromArray(schema, base, ref) {
|
|
78
|
-
return schema.reduce((result, item) => {
|
|
79
|
-
const match = FromValue(item, base, ref);
|
|
80
|
-
return !Guard.IsUndefined(match) ? match : result;
|
|
81
|
-
}, undefined);
|
|
82
|
-
}
|
|
83
|
-
// ------------------------------------------------------------------
|
|
84
|
-
// FromObject
|
|
85
|
-
// ------------------------------------------------------------------
|
|
86
|
-
function FromObject(schema, base, ref) {
|
|
87
|
-
return Guard.Keys(schema).reduce((result, key) => {
|
|
88
|
-
const match = FromValue(schema[key], base, ref);
|
|
89
|
-
return !Guard.IsUndefined(match) ? match : result;
|
|
90
|
-
}, undefined);
|
|
91
|
-
}
|
|
92
|
-
// ------------------------------------------------------------------
|
|
93
|
-
// FromValue
|
|
94
|
-
// ------------------------------------------------------------------
|
|
95
|
-
function FromValue(schema, base, ref) {
|
|
96
|
-
const nextBase = Schema.IsSchemaObject(schema) && Schema.IsId(schema)
|
|
97
|
-
? new URL(schema.$id, base.href)
|
|
98
|
-
: base;
|
|
99
|
-
if (Schema.IsSchemaObject(schema)) {
|
|
100
|
-
const result = Match(schema, nextBase, ref);
|
|
101
|
-
if (!Guard.IsUndefined(result))
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
if (Guard.IsArray(schema))
|
|
105
|
-
return FromArray(schema, nextBase, ref);
|
|
106
|
-
if (Guard.IsObject(schema))
|
|
107
|
-
return FromObject(schema, nextBase, ref);
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
// ------------------------------------------------------------------
|
|
111
|
-
// Ref
|
|
112
|
-
// ------------------------------------------------------------------
|
|
113
|
-
export function Ref(schema, ref) {
|
|
114
|
-
const defaultBase = new URL('http://unknown/');
|
|
115
|
-
const initialBase = Schema.IsId(schema) ? new URL(schema.$id, defaultBase.href) : defaultBase;
|
|
116
|
-
const initialRef = new URL(ref, initialBase.href);
|
|
117
|
-
return FromValue(schema, initialBase, initialRef);
|
|
118
|
-
}
|
|
119
|
-
// ------------------------------------------------------------------
|
|
120
|
-
// DynamicRef
|
|
121
|
-
// ------------------------------------------------------------------
|
|
122
|
-
export function DynamicRef(root, base, dynamicRef, dynamicAnchors) {
|
|
123
|
-
// Resolve the static target using either the local base (for fragment‑only references)
|
|
124
|
-
// or the document root (for absolute URI references).
|
|
125
|
-
const fragmentTarget = dynamicRef.$dynamicRef.startsWith('#')
|
|
126
|
-
? Ref(base, dynamicRef.$dynamicRef)
|
|
127
|
-
: Ref(root, dynamicRef.$dynamicRef);
|
|
128
|
-
if (Guard.IsUndefined(fragmentTarget))
|
|
129
|
-
return undefined;
|
|
130
|
-
// Dynamic override only applies if the resolved target itself declares a $dynamicAnchor.
|
|
131
|
-
// If it does not, return the static target unchanged.
|
|
132
|
-
if (!Schema.IsSchemaObject(fragmentTarget) || !Schema.IsDynamicAnchor(fragmentTarget))
|
|
133
|
-
return fragmentTarget;
|
|
134
|
-
// Extract the fragment portion of the reference. According to the test suite,
|
|
135
|
-
// only plain fragment names (e.g., "#foo") trigger the dynamic scope; JSON
|
|
136
|
-
// Pointer fragments (e.g., "#/definitions/foo") bypass dynamic resolution.
|
|
137
|
-
const fragment = new URL(dynamicRef.$dynamicRef, 'http://unknown/').hash;
|
|
138
|
-
if (fragment.startsWith('#/'))
|
|
139
|
-
return fragmentTarget;
|
|
140
|
-
// Search the live dynamic anchor stack for a schema whose $dynamicAnchor matches the
|
|
141
|
-
// target's $dynamicAnchor. The stack reflects the current evaluation path, and
|
|
142
|
-
// find() returns the outermost (first encountered) match, which is the correct
|
|
143
|
-
// lexical scope per the specification.
|
|
144
|
-
const anchorTarget = dynamicAnchors.find(anchor => anchor.$dynamicAnchor === fragmentTarget.$dynamicAnchor);
|
|
145
|
-
return anchorTarget ?? fragmentTarget;
|
|
146
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type XSchemaObject } from './schema.mjs';
|
|
2
|
-
export interface XContentEncoding<ContentEncoding extends string = string> {
|
|
3
|
-
contentEncoding: ContentEncoding;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Returns true if the schema contains a valid contentEncoding property
|
|
7
|
-
* @specification Json Schema 7
|
|
8
|
-
*/
|
|
9
|
-
export declare function IsContentEncoding(schema: XSchemaObject): schema is XContentEncoding;
|