@psnext/slingcli 3.0.20260811-2 → 3.0.20260814-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.
Files changed (79) hide show
  1. package/node_modules/@aws-sdk/core/package.json +4 -4
  2. package/node_modules/@aws-sdk/credential-provider-env/package.json +4 -4
  3. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-cjs/index.js +9 -2
  4. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +9 -2
  5. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/package.json +4 -8
  6. package/node_modules/@aws-sdk/credential-provider-http/package.json +4 -4
  7. package/node_modules/@aws-sdk/credential-provider-ini/package.json +11 -11
  8. package/node_modules/@aws-sdk/credential-provider-login/package.json +5 -5
  9. package/node_modules/@aws-sdk/credential-provider-node/package.json +9 -9
  10. package/node_modules/@aws-sdk/credential-provider-process/package.json +4 -4
  11. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +5 -5
  12. package/node_modules/@aws-sdk/credential-provider-sso/package.json +6 -6
  13. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +5 -5
  14. package/node_modules/@aws-sdk/eventstream-handler-node/package.json +3 -3
  15. package/node_modules/@aws-sdk/middleware-eventstream/package.json +3 -3
  16. package/node_modules/@aws-sdk/middleware-websocket/package.json +4 -4
  17. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  18. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  19. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  20. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  21. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  22. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-cjs/index.js +9 -2
  23. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +9 -2
  24. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/package.json +4 -8
  25. package/node_modules/@aws-sdk/nested-clients/package.json +5 -5
  26. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +3 -3
  27. package/node_modules/@aws-sdk/types/package.json +2 -2
  28. package/node_modules/@aws-sdk/util-locate-window/package.json +27 -27
  29. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  30. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +4 -1
  31. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +6 -5
  32. package/node_modules/@hono/node-server/dist/index.cjs +151 -9
  33. package/node_modules/@hono/node-server/dist/index.mjs +151 -9
  34. package/node_modules/@hono/node-server/package.json +1 -1
  35. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +8 -5
  36. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +0 -10
  37. package/node_modules/@smithy/core/dist-es/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.js +8 -5
  38. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +0 -2
  39. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +0 -2
  40. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/OperationSchema.js +0 -2
  41. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +0 -2
  42. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +0 -2
  43. package/node_modules/@smithy/core/dist-types/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +7 -2
  44. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +7 -2
  45. package/node_modules/@smithy/core/package.json +2 -6
  46. package/node_modules/@smithy/credential-provider-imds/package.json +3 -3
  47. package/node_modules/@smithy/fetch-http-handler/package.json +4 -4
  48. package/node_modules/@smithy/signature-v4/package.json +3 -3
  49. package/node_modules/@smithy/types/dist-types/schema/sentinels.d.ts +14 -14
  50. package/node_modules/@smithy/types/package.json +33 -35
  51. package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
  52. package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
  53. package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
  54. package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
  55. package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
  56. package/node_modules/gaxios/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  57. package/node_modules/gaxios/build/esm/tsconfig.tsbuildinfo +1 -1
  58. package/node_modules/gaxios/package.json +3 -3
  59. package/node_modules/hono/dist/cjs/client/client.js +3 -3
  60. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +1 -1
  61. package/node_modules/hono/dist/cjs/middleware/cors/index.js +15 -12
  62. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +47 -1
  63. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
  64. package/node_modules/hono/dist/cjs/utils/url.js +2 -2
  65. package/node_modules/hono/dist/client/client.js +3 -3
  66. package/node_modules/hono/dist/jsx/intrinsic-element/components.js +1 -1
  67. package/node_modules/hono/dist/middleware/cors/index.js +15 -12
  68. package/node_modules/hono/dist/middleware/etag/digest.js +47 -1
  69. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
  70. package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
  71. package/node_modules/hono/dist/utils/url.js +2 -2
  72. package/node_modules/hono/package.json +1 -1
  73. package/node_modules/type-is/node_modules/content-type/README.md +2 -0
  74. package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
  75. package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
  76. package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
  77. package/node_modules/type-is/node_modules/content-type/package.json +1 -1
  78. package/package.json +2 -2
  79. package/slingshot/index.js +184 -181
@@ -140,8 +140,6 @@ class Schema {
140
140
 
141
141
  class ListSchema extends Schema {
142
142
  static symbol = Symbol.for("@smithy/lis");
143
- name;
144
- traits;
145
143
  valueSchema;
146
144
  symbol = ListSchema.symbol;
147
145
  }
@@ -154,8 +152,6 @@ const list = (namespace, name, traits, valueSchema) => Schema.assign(new ListSch
154
152
 
155
153
  class MapSchema extends Schema {
156
154
  static symbol = Symbol.for("@smithy/map");
157
- name;
158
- traits;
159
155
  keySchema;
160
156
  valueSchema;
161
157
  symbol = MapSchema.symbol;
@@ -170,8 +166,6 @@ const map = (namespace, name, traits, keySchema, valueSchema) => Schema.assign(n
170
166
 
171
167
  class OperationSchema extends Schema {
172
168
  static symbol = Symbol.for("@smithy/ope");
173
- name;
174
- traits;
175
169
  input;
176
170
  output;
177
171
  symbol = OperationSchema.symbol;
@@ -186,8 +180,6 @@ const op = (namespace, name, traits, input, output) => Schema.assign(new Operati
186
180
 
187
181
  class StructureSchema extends Schema {
188
182
  static symbol = Symbol.for("@smithy/str");
189
- name;
190
- traits;
191
183
  memberNames;
192
184
  memberList;
193
185
  symbol = StructureSchema.symbol;
@@ -545,9 +537,7 @@ const isStaticSchema = (sc) => Array.isArray(sc) && sc.length >= 5;
545
537
 
546
538
  class SimpleSchema extends Schema {
547
539
  static symbol = Symbol.for("@smithy/sim");
548
- name;
549
540
  schemaRef;
550
- traits;
551
541
  symbol = SimpleSchema.symbol;
552
542
  }
553
543
  const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
@@ -1,21 +1,24 @@
1
1
  export const getHttpHandlerExtensionConfiguration = (runtimeConfig) => {
2
+ if (runtimeConfig.logger && runtimeConfig.logger.constructor?.name !== "NoOpLogger") {
3
+ runtimeConfig.requestHandler?.updateHttpClientConfig?.(Symbol.for("logger"), runtimeConfig.logger);
4
+ }
2
5
  return {
3
6
  setHttpHandler(handler) {
4
- runtimeConfig.httpHandler = handler;
7
+ runtimeConfig.requestHandler = handler;
5
8
  },
6
9
  httpHandler() {
7
- return runtimeConfig.httpHandler;
10
+ return runtimeConfig.requestHandler;
8
11
  },
9
12
  updateHttpClientConfig(key, value) {
10
- runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);
13
+ runtimeConfig.requestHandler?.updateHttpClientConfig(key, value);
11
14
  },
12
15
  httpHandlerConfigs() {
13
- return runtimeConfig.httpHandler.httpHandlerConfigs();
16
+ return runtimeConfig.requestHandler.httpHandlerConfigs();
14
17
  },
15
18
  };
16
19
  };
17
20
  export const resolveHttpHandlerRuntimeConfig = (httpHandlerExtensionConfiguration) => {
18
21
  return {
19
- httpHandler: httpHandlerExtensionConfiguration.httpHandler(),
22
+ requestHandler: httpHandlerExtensionConfiguration.httpHandler(),
20
23
  };
21
24
  };
@@ -1,8 +1,6 @@
1
1
  import { Schema } from "./Schema";
2
2
  export class ListSchema extends Schema {
3
3
  static symbol = Symbol.for("@smithy/lis");
4
- name;
5
- traits;
6
4
  valueSchema;
7
5
  symbol = ListSchema.symbol;
8
6
  }
@@ -1,8 +1,6 @@
1
1
  import { Schema } from "./Schema";
2
2
  export class MapSchema extends Schema {
3
3
  static symbol = Symbol.for("@smithy/map");
4
- name;
5
- traits;
6
4
  keySchema;
7
5
  valueSchema;
8
6
  symbol = MapSchema.symbol;
@@ -1,8 +1,6 @@
1
1
  import { Schema } from "./Schema";
2
2
  export class OperationSchema extends Schema {
3
3
  static symbol = Symbol.for("@smithy/ope");
4
- name;
5
- traits;
6
4
  input;
7
5
  output;
8
6
  symbol = OperationSchema.symbol;
@@ -1,9 +1,7 @@
1
1
  import { Schema } from "./Schema";
2
2
  export class SimpleSchema extends Schema {
3
3
  static symbol = Symbol.for("@smithy/sim");
4
- name;
5
4
  schemaRef;
6
- traits;
7
5
  symbol = SimpleSchema.symbol;
8
6
  }
9
7
  export const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
@@ -1,8 +1,6 @@
1
1
  import { Schema } from "./Schema";
2
2
  export class StructureSchema extends Schema {
3
3
  static symbol = Symbol.for("@smithy/str");
4
- name;
5
- traits;
6
4
  memberNames;
7
5
  memberList;
8
6
  symbol = StructureSchema.symbol;
@@ -1,3 +1,4 @@
1
+ import type { Logger } from "@smithy/types";
1
2
  import type { HttpHandler } from "../httpHandler";
2
3
  /**
3
4
  * @internal
@@ -12,14 +13,18 @@ export interface HttpHandlerExtensionConfiguration<HandlerConfig extends object
12
13
  * @internal
13
14
  */
14
15
  export type HttpHandlerExtensionConfigType<HandlerConfig extends object = {}> = Partial<{
15
- httpHandler: HttpHandler<HandlerConfig>;
16
+ requestHandler: HttpHandler<HandlerConfig>;
16
17
  }>;
17
18
  /**
18
19
  * Helper function to resolve default extension configuration from runtime config
19
20
  *
20
21
  * @internal
21
22
  */
22
- export declare const getHttpHandlerExtensionConfiguration: <HandlerConfig extends object = {}>(runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig>) => {
23
+ export declare const getHttpHandlerExtensionConfiguration: <HandlerConfig extends {
24
+ logger?: Logger;
25
+ }>(runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig> & {
26
+ logger?: Logger;
27
+ }) => {
23
28
  setHttpHandler(handler: HttpHandler<HandlerConfig>): void;
24
29
  httpHandler(): HttpHandler<HandlerConfig>;
25
30
  updateHttpClientConfig(key: keyof HandlerConfig, value: HandlerConfig[typeof key]): void;
@@ -1,3 +1,4 @@
1
+ import { Logger } from "@smithy/types";
1
2
  import { HttpHandler } from "../httpHandler";
2
3
  /**
3
4
  * @internal
@@ -12,14 +13,18 @@ export interface HttpHandlerExtensionConfiguration<HandlerConfig extends object
12
13
  * @internal
13
14
  */
14
15
  export type HttpHandlerExtensionConfigType<HandlerConfig extends object = {}> = Partial<{
15
- httpHandler: HttpHandler<HandlerConfig>;
16
+ requestHandler: HttpHandler<HandlerConfig>;
16
17
  }>;
17
18
  /**
18
19
  * Helper function to resolve default extension configuration from runtime config
19
20
  *
20
21
  * @internal
21
22
  */
22
- export declare const getHttpHandlerExtensionConfiguration: <HandlerConfig extends object = {}>(runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig>) => {
23
+ export declare const getHttpHandlerExtensionConfiguration: <HandlerConfig extends {
24
+ logger?: Logger;
25
+ }>(runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig> & {
26
+ logger?: Logger;
27
+ }) => {
23
28
  setHttpHandler(handler: HttpHandler<HandlerConfig>): void;
24
29
  httpHandler(): HttpHandler<HandlerConfig>;
25
30
  updateHttpClientConfig(key: keyof HandlerConfig, value: HandlerConfig[typeof key]): void;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.31.1",
3
+ "version": "3.33.0",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -214,9 +214,6 @@
214
214
  "require": "./dist-cjs/submodules/transport/index.js"
215
215
  }
216
216
  },
217
- "publishConfig": {
218
- "directory": ".release/package"
219
- },
220
217
  "scripts": {
221
218
  "benchmark:cbor": "node ./scripts/cbor-perf.mjs",
222
219
  "benchmark:checksum": "node ./scripts/checksum-perf.mjs",
@@ -229,14 +226,13 @@
229
226
  "extract:docs": "api-extractor run --local",
230
227
  "lint": "node ../../scripts/validation/submodules-linter.js",
231
228
  "prebuild": "yarn lint",
232
- "stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
233
229
  "test": "yarn g:vitest run",
234
230
  "test:watch": "yarn g:vitest watch",
235
231
  "test:integration": "yarn g:vitest run -c vitest.config.integ.mts",
236
232
  "test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
237
233
  },
238
234
  "dependencies": {
239
- "@smithy/types": "^4.16.1",
235
+ "@smithy/types": "^4.17.0",
240
236
  "tslib": "^2.6.2"
241
237
  },
242
238
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/credential-provider-imds",
3
- "version": "4.4.16",
3
+ "version": "4.5.0",
4
4
  "description": "AWS credential provider that sources credentials from the EC2 instance metadata service and ECS container metadata service",
5
5
  "keywords": [
6
6
  "aws",
@@ -45,8 +45,8 @@
45
45
  "test:watch": "yarn g:vitest watch"
46
46
  },
47
47
  "dependencies": {
48
- "@smithy/core": "^3.31.1",
49
- "@smithy/types": "^4.16.1",
48
+ "@smithy/core": "^3.32.0",
49
+ "@smithy/types": "^4.17.0",
50
50
  "tslib": "^2.6.2"
51
51
  },
52
52
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/fetch-http-handler",
3
- "version": "5.6.13",
3
+ "version": "5.7.0",
4
4
  "description": "Provides a way to make requests",
5
5
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/fetch-http-handler",
6
6
  "license": "Apache-2.0",
@@ -44,12 +44,12 @@
44
44
  "test:browser:watch": "yarn g:vitest watch -c vitest.config.browser.mts"
45
45
  },
46
46
  "dependencies": {
47
- "@smithy/core": "^3.31.1",
48
- "@smithy/types": "^4.16.1",
47
+ "@smithy/core": "^3.32.0",
48
+ "@smithy/types": "^4.17.0",
49
49
  "tslib": "^2.6.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@smithy/abort-controller": "^4.3.3",
52
+ "@smithy/abort-controller": "^4.4.0",
53
53
  "concurrently": "7.0.0",
54
54
  "downlevel-dts": "0.10.1",
55
55
  "premove": "4.0.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/signature-v4",
3
- "version": "5.6.12",
3
+ "version": "5.7.0",
4
4
  "description": "A standalone implementation of the AWS Signature V4 request signing algorithm",
5
5
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/signature-v4",
6
6
  "license": "Apache-2.0",
@@ -42,8 +42,8 @@
42
42
  "test:watch": "yarn g:vitest watch"
43
43
  },
44
44
  "dependencies": {
45
- "@smithy/core": "^3.31.1",
46
- "@smithy/types": "^4.16.1",
45
+ "@smithy/core": "^3.32.0",
46
+ "@smithy/types": "^4.17.0",
47
47
  "tslib": "^2.6.2"
48
48
  },
49
49
  "devDependencies": {
@@ -3,63 +3,63 @@
3
3
  * such as Buffer, string, or Readable(Stream) depending on circumstances.
4
4
  * @public
5
5
  */
6
- export type BlobSchema = 21;
6
+ export type BlobSchema = 0b0001_0101;
7
7
  /**
8
8
  * @public
9
9
  */
10
- export type StreamingBlobSchema = 42;
10
+ export type StreamingBlobSchema = 0b0010_1010;
11
11
  /**
12
12
  * @public
13
13
  */
14
- export type BooleanSchema = 2;
14
+ export type BooleanSchema = 0b0000_0010;
15
15
  /**
16
16
  * Includes string and enum Smithy types.
17
17
  * @public
18
18
  */
19
- export type StringSchema = 0;
19
+ export type StringSchema = 0b0000_0000;
20
20
  /**
21
21
  * Includes all numeric Smithy types except bigInteger and bigDecimal.
22
22
  * byte, short, integer, long, float, double, intEnum.
23
23
  *
24
24
  * @public
25
25
  */
26
- export type NumericSchema = 1;
26
+ export type NumericSchema = 0b0000_0001;
27
27
  /**
28
28
  * @public
29
29
  */
30
- export type BigIntegerSchema = 17;
30
+ export type BigIntegerSchema = 0b0001_0001;
31
31
  /**
32
32
  * @public
33
33
  */
34
- export type BigDecimalSchema = 19;
34
+ export type BigDecimalSchema = 0b0001_0011;
35
35
  /**
36
36
  * @public
37
37
  */
38
- export type DocumentSchema = 15;
38
+ export type DocumentSchema = 0b0000_1111;
39
39
  /**
40
40
  * Smithy type timestamp, in JS as native Date object.
41
41
  * @public
42
42
  */
43
- export type TimestampDefaultSchema = 4;
43
+ export type TimestampDefaultSchema = 0b0000_0100;
44
44
  /**
45
45
  * @public
46
46
  */
47
- export type TimestampDateTimeSchema = 5;
47
+ export type TimestampDateTimeSchema = 0b0000_0101;
48
48
  /**
49
49
  * @public
50
50
  */
51
- export type TimestampHttpDateSchema = 6;
51
+ export type TimestampHttpDateSchema = 0b0000_0110;
52
52
  /**
53
53
  * @public
54
54
  */
55
- export type TimestampEpochSecondsSchema = 7;
55
+ export type TimestampEpochSecondsSchema = 0b0000_0111;
56
56
  /**
57
57
  * Additional bit indicating the type is a list.
58
58
  * @public
59
59
  */
60
- export type ListSchemaModifier = 64;
60
+ export type ListSchemaModifier = 0b0100_0000;
61
61
  /**
62
62
  * Additional bit indicating the type is a map.
63
63
  * @public
64
64
  */
65
- export type MapSchemaModifier = 128;
65
+ export type MapSchemaModifier = 0b1000_0000;
@@ -1,28 +1,45 @@
1
1
  {
2
2
  "name": "@smithy/types",
3
- "version": "4.16.1",
3
+ "version": "4.17.0",
4
+ "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/types",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "AWS Smithy Team",
8
+ "email": "",
9
+ "url": "https://smithy.io"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/smithy-lang/smithy-typescript.git",
14
+ "directory": "packages/types"
15
+ },
16
+ "files": [
17
+ "dist-*/**"
18
+ ],
19
+ "sideEffects": false,
20
+ "main": "./dist-cjs/index.js",
21
+ "module": "./dist-es/index.js",
22
+ "types": "./dist-types/index.d.ts",
23
+ "typesVersions": {
24
+ "<=4.5": {
25
+ "dist-types/*": [
26
+ "dist-types/ts3.4/*"
27
+ ]
28
+ }
29
+ },
30
+ "publishConfig": {
31
+ "directory": ".release/package"
32
+ },
4
33
  "scripts": {
5
34
  "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
6
- "build:es:cjs": "premove dist-es && yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline",
35
+ "build:es:cjs": "node ../../scripts/compilation/es_cjs.js",
7
36
  "build:types": "premove dist-types && yarn g:tsc -p tsconfig.types.json",
8
37
  "build:types:downlevel": "premove dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4 && node scripts/downlevel",
9
38
  "clean": "premove dist-cjs dist-es dist-types",
10
39
  "extract:docs": "api-extractor run --local",
11
- "format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
12
- "lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
13
40
  "stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
14
41
  "test": "yarn g:tsc -p tsconfig.test.json"
15
42
  },
16
- "main": "./dist-cjs/index.js",
17
- "module": "./dist-es/index.js",
18
- "types": "./dist-types/index.d.ts",
19
- "author": {
20
- "name": "AWS Smithy Team",
21
- "email": "",
22
- "url": "https://smithy.io"
23
- },
24
- "license": "Apache-2.0",
25
- "sideEffects": false,
26
43
  "dependencies": {
27
44
  "tslib": "^2.6.2"
28
45
  },
@@ -32,29 +49,10 @@
32
49
  "premove": "4.0.0",
33
50
  "typedoc": "0.23.23"
34
51
  },
35
- "engines": {
36
- "node": ">=18.0.0"
37
- },
38
- "typesVersions": {
39
- "<=4.5": {
40
- "dist-types/*": [
41
- "dist-types/ts3.4/*"
42
- ]
43
- }
44
- },
45
- "files": [
46
- "dist-*/**"
47
- ],
48
- "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/types",
49
- "repository": {
50
- "type": "git",
51
- "url": "https://github.com/smithy-lang/smithy-typescript.git",
52
- "directory": "packages/types"
53
- },
54
52
  "typedoc": {
55
53
  "entryPoint": "src/index.ts"
56
54
  },
57
- "publishConfig": {
58
- "directory": ".release/package"
55
+ "engines": {
56
+ "node": ">=18.0.0"
59
57
  }
60
58
  }
@@ -36,6 +36,8 @@ The parser is lenient and does not error. You should validate `type` and `parame
36
36
  #### Options
37
37
 
38
38
  - `parameters` (default: `true`): Set to `false` to skip parameters.
39
+ - `comma` (default: `false`): Set to `true` to stop on a comma. This can be used to parse the media range in an `Accept` header.
40
+ - `start` (default: `0`): Set index to start parsing from.
39
41
 
40
42
  ### contentType.format(obj)
41
43
 
@@ -8,6 +8,7 @@
8
8
  */
9
9
  export interface ContentType {
10
10
  type: string;
11
+ index: number;
11
12
  parameters: Record<string, string>;
12
13
  }
13
14
  /**
@@ -18,7 +19,26 @@ export declare function format(obj: Partial<ContentType>): string;
18
19
  * Options for parsing a `Content-Type` header.
19
20
  */
20
21
  export interface ParseOptions {
22
+ /**
23
+ * Exit early on the first semicolon, returning only the type.
24
+ * This is useful for parsing the MIME from `Content-Type` headers.
25
+ *
26
+ * @default false
27
+ */
21
28
  parameters?: boolean;
29
+ /**
30
+ * Exits early on a comma, returning the first value and parameters.
31
+ * This is useful for parsing `Accept` headers.
32
+ *
33
+ * @default false
34
+ */
35
+ comma?: boolean;
36
+ /**
37
+ * The index to start parsing from.
38
+ *
39
+ * @default 0
40
+ */
41
+ start?: number;
22
42
  }
23
43
  /**
24
44
  * Parse a `Content-Type` header.
@@ -52,16 +52,17 @@ function format(obj) {
52
52
  * Parse a `Content-Type` header.
53
53
  */
54
54
  function parse(header, options) {
55
+ const stopChar = options?.comma === true ? COMMA : 65536; // Sentinel for "no stop char".
55
56
  const len = header.length;
56
- let index = skipOWS(header, 0, len);
57
+ let index = skipOWS(header, options?.start ?? 0, len);
57
58
  const valueStart = index;
58
- index = skipValue(header, index, len);
59
+ index = skipValue(header, index, len, stopChar);
59
60
  const valueEnd = trailingOWS(header, valueStart, index);
60
61
  const type = header.slice(valueStart, valueEnd).toLowerCase();
61
- const parameters = options?.parameters === false
62
- ? new NullObject()
63
- : parseParameters(header, index, len);
64
- return { type, parameters };
62
+ if (options?.parameters === false) {
63
+ return { type, index, parameters: new NullObject() };
64
+ }
65
+ return parseParameters(header, type, index, len, stopChar);
65
66
  }
66
67
  const SP = 32; // " "
67
68
  const HTAB = 9; // "\t"
@@ -69,16 +70,21 @@ const SEMI = 59; // ";"
69
70
  const EQ = 61; // "="
70
71
  const DQUOTE = 34; // '"'
71
72
  const BSLASH = 92; // "\\"
73
+ const COMMA = 44; // ","
72
74
  /**
73
75
  * Parses the parameters of a `Content-Type` header starting at the given index.
74
76
  */
75
- function parseParameters(header, index, len) {
77
+ function parseParameters(header, type, index, len, stopChar) {
76
78
  const parameters = new NullObject();
77
79
  parameter: while (index < len) {
80
+ if (header.charCodeAt(index) === stopChar)
81
+ break;
78
82
  index = skipOWS(header, index + 1 /* Skip over ; */, len);
79
83
  const keyStart = index;
80
84
  while (index < len) {
81
85
  const code = header.charCodeAt(index);
86
+ if (code === stopChar)
87
+ break parameter;
82
88
  if (code === SEMI)
83
89
  continue parameter;
84
90
  if (code === EQ) {
@@ -91,7 +97,7 @@ function parseParameters(header, index, len) {
91
97
  while (index < len) {
92
98
  const code = header.charCodeAt(index++);
93
99
  if (code === DQUOTE) {
94
- index = skipValue(header, index, len);
100
+ index = skipValue(header, index, len, stopChar);
95
101
  if (parameters[key] === undefined)
96
102
  parameters[key] = value;
97
103
  break;
@@ -105,7 +111,7 @@ function parseParameters(header, index, len) {
105
111
  continue parameter;
106
112
  }
107
113
  const valueStart = index;
108
- index = skipValue(header, index, len);
114
+ index = skipValue(header, index, len, stopChar);
109
115
  if (parameters[key] === undefined) {
110
116
  const valueEnd = trailingOWS(header, valueStart, index);
111
117
  parameters[key] = header.slice(valueStart, valueEnd);
@@ -115,15 +121,15 @@ function parseParameters(header, index, len) {
115
121
  index++;
116
122
  }
117
123
  }
118
- return parameters;
124
+ return { type, index, parameters };
119
125
  }
120
126
  /**
121
- * Skip over characters until a semicolon.
127
+ * Skip over characters until a semicolon or other exit character.
122
128
  */
123
- function skipValue(str, index, len) {
129
+ function skipValue(str, index, len, stopChar) {
124
130
  while (index < len) {
125
- const char = str.charCodeAt(index);
126
- if (char === SEMI)
131
+ const code = str.charCodeAt(index);
132
+ if (code === SEMI || code === stopChar)
127
133
  break;
128
134
  index++;
129
135
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAwCH,w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AAC,CAAC;QACxC,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM;QACxC,GAAG,EAAE,CAAC;IACR,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,GAAW;IAC1B,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;IAE3E,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nconst TEXT_REGEXP = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * RegExp to match type in RFC 9110 sec 8.3.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nconst TYPE_REGEXP =\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * The content type object contains a type string and optional parameters.\n */\nexport interface ContentType {\n type: string;\n parameters: Record<string, string>;\n}\n\n/**\n * Format an object into a `Content-Type` header.\n */\nexport function format(obj: Partial<ContentType>): string {\n const { type, parameters } = obj;\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError(`Invalid type: ${type}`);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError(`Invalid parameter name: ${param}`);\n }\n\n result += `; ${param}=${qstring(parameters[param])}`;\n }\n }\n\n return result;\n}\n\n/**\n * Options for parsing a `Content-Type` header.\n */\nexport interface ParseOptions {\n parameters?: boolean;\n}\n\n/**\n * Parse a `Content-Type` header.\n */\nexport function parse(header: string, options?: ParseOptions): ContentType {\n const len = header.length;\n let index = skipOWS(header, 0, len);\n\n const valueStart = index;\n index = skipValue(header, index, len);\n const valueEnd = trailingOWS(header, valueStart, index);\n const type = header.slice(valueStart, valueEnd).toLowerCase();\n const parameters =\n options?.parameters === false\n ? new NullObject()\n : parseParameters(header, index, len);\n\n return { type, parameters };\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\n\n/**\n * Parses the parameters of a `Content-Type` header starting at the given index.\n */\nfunction parseParameters(\n header: string,\n index: number,\n len: number,\n): Record<string, string> {\n const parameters: Record<string, string> = new NullObject();\n\n parameter: while (index < len) {\n index = skipOWS(header, index + 1 /* Skip over ; */, len);\n\n const keyStart = index;\n\n while (index < len) {\n const code = header.charCodeAt(index);\n if (code === SEMI) continue parameter;\n\n if (code === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = \"\";\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = skipValue(header, index, len);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = skipValue(header, index, len);\n\n if (parameters[key] === undefined) {\n const valueEnd = trailingOWS(header, valueStart, index);\n parameters[key] = header.slice(valueStart, valueEnd);\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return parameters;\n}\n\n/**\n * Skip over characters until a semicolon.\n */\nfunction skipValue(str: string, index: number, len: number): number {\n while (index < len) {\n const char = str.charCodeAt(index);\n if (char === SEMI) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip optional whitespace (OWS) in an HTTP header value.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction skipOWS(header: string, index: number, len: number): number {\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Trim optional whitespace (OWS) from the end of a substring.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction trailingOWS(header: string, start: number, end: number): number {\n while (end > start) {\n const char = header.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\n/**\n * Serialize a parameter value.\n */\nfunction qstring(str: string): string {\n if (TOKEN_REGEXP.test(str)) return str;\n if (TEXT_REGEXP.test(str)) return `\"${str.replace(QUOTE_REGEXP, \"\\\\$&\")}\"`;\n\n throw new TypeError(`Invalid parameter value: ${str}`);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAyCH,wBAoBC;AA+BD,sBAeC;AAzGD,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAC5D,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;GAEG;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,GACf,4DAA4D,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,GAAG,eAA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E,MAAM;QACxC,KAAK,EAAE,CAAC;IACV,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,MAAc,EAAE,KAAa,EAAE,GAAW;IAC7D,OAAO,GAAG,GAAG,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACxC,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM;QACxC,GAAG,EAAE,CAAC;IACR,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,GAAW;IAC1B,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;IAE3E,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nconst TEXT_REGEXP = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * RegExp to match type in RFC 9110 sec 8.3.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nconst TYPE_REGEXP =\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * The content type object contains a type string and optional parameters.\n */\nexport interface ContentType {\n type: string;\n index: number;\n parameters: Record<string, string>;\n}\n\n/**\n * Format an object into a `Content-Type` header.\n */\nexport function format(obj: Partial<ContentType>): string {\n const { type, parameters } = obj;\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError(`Invalid type: ${type}`);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError(`Invalid parameter name: ${param}`);\n }\n\n result += `; ${param}=${qstring(parameters[param])}`;\n }\n }\n\n return result;\n}\n\n/**\n * Options for parsing a `Content-Type` header.\n */\nexport interface ParseOptions {\n /**\n * Exit early on the first semicolon, returning only the type.\n * This is useful for parsing the MIME from `Content-Type` headers.\n *\n * @default false\n */\n parameters?: boolean;\n /**\n * Exits early on a comma, returning the first value and parameters.\n * This is useful for parsing `Accept` headers.\n *\n * @default false\n */\n comma?: boolean;\n /**\n * The index to start parsing from.\n *\n * @default 0\n */\n start?: number;\n}\n\n/**\n * Parse a `Content-Type` header.\n */\nexport function parse(header: string, options?: ParseOptions): ContentType {\n const stopChar = options?.comma === true ? COMMA : 65_536; // Sentinel for \"no stop char\".\n const len = header.length;\n let index = skipOWS(header, options?.start ?? 0, len);\n\n const valueStart = index;\n index = skipValue(header, index, len, stopChar);\n const valueEnd = trailingOWS(header, valueStart, index);\n const type = header.slice(valueStart, valueEnd).toLowerCase();\n\n if (options?.parameters === false) {\n return { type, index, parameters: new NullObject() };\n }\n\n return parseParameters(header, type, index, len, stopChar);\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\nconst COMMA = 44; // \",\"\n\n/**\n * Parses the parameters of a `Content-Type` header starting at the given index.\n */\nfunction parseParameters(\n header: string,\n type: string,\n index: number,\n len: number,\n stopChar: number,\n): ContentType {\n const parameters: Record<string, string> = new NullObject();\n\n parameter: while (index < len) {\n if (header.charCodeAt(index) === stopChar) break;\n\n index = skipOWS(header, index + 1 /* Skip over ; */, len);\n\n const keyStart = index;\n\n while (index < len) {\n const code = header.charCodeAt(index);\n if (code === stopChar) break parameter;\n\n if (code === SEMI) continue parameter;\n\n if (code === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = \"\";\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = skipValue(header, index, len, stopChar);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = skipValue(header, index, len, stopChar);\n\n if (parameters[key] === undefined) {\n const valueEnd = trailingOWS(header, valueStart, index);\n parameters[key] = header.slice(valueStart, valueEnd);\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return { type, index, parameters };\n}\n\n/**\n * Skip over characters until a semicolon or other exit character.\n */\nfunction skipValue(\n str: string,\n index: number,\n len: number,\n stopChar: number,\n): number {\n while (index < len) {\n const code = str.charCodeAt(index);\n if (code === SEMI || code === stopChar) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip optional whitespace (OWS) in an HTTP header value.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction skipOWS(header: string, index: number, len: number): number {\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Trim optional whitespace (OWS) from the end of a substring.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction trailingOWS(header: string, start: number, end: number): number {\n while (end > start) {\n const char = header.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\n/**\n * Serialize a parameter value.\n */\nfunction qstring(str: string): string {\n if (TOKEN_REGEXP.test(str)) return str;\n if (TEXT_REGEXP.test(str)) return `\"${str.replace(QUOTE_REGEXP, \"\\\\$&\")}\"`;\n\n throw new TypeError(`Invalid parameter value: ${str}`);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "content-type",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Create and parse HTTP Content-Type header",
5
5
  "keywords": [
6
6
  "content-type",