@atproto/oauth-scopes 0.0.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/atproto-oauth-scope.d.ts +17 -0
  3. package/dist/atproto-oauth-scope.d.ts.map +1 -0
  4. package/dist/atproto-oauth-scope.js +67 -0
  5. package/dist/atproto-oauth-scope.js.map +1 -0
  6. package/dist/index.d.ts +9 -13
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +9 -13
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/lexicon.d.ts +2 -0
  11. package/dist/lib/lexicon.d.ts.map +1 -0
  12. package/dist/lib/lexicon.js +3 -0
  13. package/dist/lib/lexicon.js.map +1 -0
  14. package/dist/lib/mime.d.ts +1 -1
  15. package/dist/lib/mime.d.ts.map +1 -1
  16. package/dist/lib/mime.js +2 -0
  17. package/dist/lib/mime.js.map +1 -1
  18. package/dist/lib/nsid.d.ts +2 -2
  19. package/dist/lib/nsid.d.ts.map +1 -1
  20. package/dist/lib/nsid.js +4 -6
  21. package/dist/lib/nsid.js.map +1 -1
  22. package/dist/lib/parser.d.ts +29 -0
  23. package/dist/lib/parser.d.ts.map +1 -0
  24. package/dist/lib/parser.js +152 -0
  25. package/dist/lib/parser.js.map +1 -0
  26. package/dist/lib/resource-permission.d.ts +10 -0
  27. package/dist/lib/resource-permission.d.ts.map +1 -0
  28. package/dist/lib/resource-permission.js +3 -0
  29. package/dist/lib/resource-permission.js.map +1 -0
  30. package/dist/lib/syntax-lexicon.d.ts +26 -0
  31. package/dist/lib/syntax-lexicon.d.ts.map +1 -0
  32. package/dist/lib/syntax-lexicon.js +58 -0
  33. package/dist/lib/syntax-lexicon.js.map +1 -0
  34. package/dist/lib/syntax-string.d.ts +16 -0
  35. package/dist/lib/syntax-string.d.ts.map +1 -0
  36. package/dist/lib/syntax-string.js +121 -0
  37. package/dist/lib/syntax-string.js.map +1 -0
  38. package/dist/lib/syntax.d.ts +23 -0
  39. package/dist/lib/syntax.d.ts.map +1 -0
  40. package/dist/lib/syntax.js +22 -0
  41. package/dist/lib/syntax.js.map +1 -0
  42. package/dist/lib/util.d.ts +5 -1
  43. package/dist/lib/util.d.ts.map +1 -1
  44. package/dist/lib/util.js +8 -12
  45. package/dist/lib/util.js.map +1 -1
  46. package/dist/scope-permissions-transition.d.ts +15 -0
  47. package/dist/scope-permissions-transition.d.ts.map +1 -0
  48. package/dist/{permission-set-transition.js → scope-permissions-transition.js} +5 -5
  49. package/dist/scope-permissions-transition.js.map +1 -0
  50. package/dist/scope-permissions.d.ts +22 -0
  51. package/dist/scope-permissions.d.ts.map +1 -0
  52. package/dist/{permission-set.js → scope-permissions.js} +20 -16
  53. package/dist/scope-permissions.js.map +1 -0
  54. package/dist/scopes/account-permission.d.ts +35 -0
  55. package/dist/scopes/account-permission.d.ts.map +1 -0
  56. package/dist/scopes/account-permission.js +71 -0
  57. package/dist/scopes/account-permission.js.map +1 -0
  58. package/dist/scopes/blob-permission.d.ts +27 -0
  59. package/dist/scopes/blob-permission.d.ts.map +1 -0
  60. package/dist/scopes/blob-permission.js +86 -0
  61. package/dist/scopes/blob-permission.js.map +1 -0
  62. package/dist/scopes/identity-permission.d.ts +25 -0
  63. package/dist/scopes/identity-permission.d.ts.map +1 -0
  64. package/dist/scopes/identity-permission.js +53 -0
  65. package/dist/scopes/identity-permission.js.map +1 -0
  66. package/dist/scopes/include-scope.d.ts +54 -0
  67. package/dist/scopes/include-scope.d.ts.map +1 -0
  68. package/dist/scopes/include-scope.js +156 -0
  69. package/dist/scopes/include-scope.js.map +1 -0
  70. package/dist/scopes/repo-permission.d.ts +40 -0
  71. package/dist/scopes/repo-permission.d.ts.map +1 -0
  72. package/dist/scopes/repo-permission.js +101 -0
  73. package/dist/scopes/repo-permission.js.map +1 -0
  74. package/dist/scopes/rpc-permission.d.ts +38 -0
  75. package/dist/scopes/rpc-permission.d.ts.map +1 -0
  76. package/dist/scopes/rpc-permission.js +81 -0
  77. package/dist/scopes/rpc-permission.js.map +1 -0
  78. package/dist/scopes-set.d.ts +12 -1
  79. package/dist/scopes-set.d.ts.map +1 -1
  80. package/dist/scopes-set.js +49 -3
  81. package/dist/scopes-set.js.map +1 -1
  82. package/package.json +7 -3
  83. package/src/atproto-oauth-scope.ts +79 -0
  84. package/src/index.ts +10 -14
  85. package/src/lib/lexicon.ts +1 -0
  86. package/src/lib/mime.ts +2 -1
  87. package/src/lib/nsid.ts +5 -6
  88. package/src/lib/parser.ts +176 -0
  89. package/src/lib/resource-permission.ts +10 -0
  90. package/src/lib/syntax-lexicon.ts +55 -0
  91. package/src/lib/syntax-string.test.ts +130 -0
  92. package/src/lib/syntax-string.ts +132 -0
  93. package/src/lib/syntax.test.ts +43 -0
  94. package/src/lib/syntax.ts +47 -0
  95. package/src/lib/util.ts +11 -12
  96. package/src/{permission-set-transition.test.ts → scope-permissions-transition.test.ts} +33 -20
  97. package/src/{permission-set-transition.ts → scope-permissions-transition.ts} +11 -11
  98. package/src/{permission-set.test.ts → scope-permissions.test.ts} +77 -35
  99. package/src/scope-permissions.ts +91 -0
  100. package/src/{resources/account-scope.test.ts → scopes/account-permission.test.ts} +45 -33
  101. package/src/scopes/account-permission.ts +75 -0
  102. package/src/{resources/blob-scope.test.ts → scopes/blob-permission.test.ts} +31 -23
  103. package/src/scopes/blob-permission.ts +105 -0
  104. package/src/{resources/identity-scope.test.ts → scopes/identity-permission.test.ts} +13 -13
  105. package/src/scopes/identity-permission.ts +54 -0
  106. package/src/scopes/include-scope.test.ts +626 -0
  107. package/src/scopes/include-scope.ts +168 -0
  108. package/src/{resources/repo-scope.test.ts → scopes/repo-permission.test.ts} +77 -65
  109. package/src/scopes/repo-permission.ts +111 -0
  110. package/src/scopes/rpc-permission.test.ts +323 -0
  111. package/src/scopes/rpc-permission.ts +85 -0
  112. package/src/scopes-set.test.ts +5 -5
  113. package/src/scopes-set.ts +79 -5
  114. package/tsconfig.build.tsbuildinfo +1 -1
  115. package/tsconfig.tests.tsbuildinfo +1 -1
  116. package/dist/lib/did.d.ts +0 -3
  117. package/dist/lib/did.d.ts.map +0 -1
  118. package/dist/lib/did.js +0 -6
  119. package/dist/lib/did.js.map +0 -1
  120. package/dist/parser.d.ts +0 -31
  121. package/dist/parser.d.ts.map +0 -1
  122. package/dist/parser.js +0 -118
  123. package/dist/parser.js.map +0 -1
  124. package/dist/permission-set-transition.d.ts +0 -15
  125. package/dist/permission-set-transition.d.ts.map +0 -1
  126. package/dist/permission-set-transition.js.map +0 -1
  127. package/dist/permission-set.d.ts +0 -22
  128. package/dist/permission-set.d.ts.map +0 -1
  129. package/dist/permission-set.js.map +0 -1
  130. package/dist/resources/account-scope.d.ts +0 -35
  131. package/dist/resources/account-scope.d.ts.map +0 -1
  132. package/dist/resources/account-scope.js +0 -60
  133. package/dist/resources/account-scope.js.map +0 -1
  134. package/dist/resources/blob-scope.d.ts +0 -25
  135. package/dist/resources/blob-scope.d.ts.map +0 -1
  136. package/dist/resources/blob-scope.js +0 -74
  137. package/dist/resources/blob-scope.js.map +0 -1
  138. package/dist/resources/identity-scope.d.ts +0 -25
  139. package/dist/resources/identity-scope.d.ts.map +0 -1
  140. package/dist/resources/identity-scope.js +0 -46
  141. package/dist/resources/identity-scope.js.map +0 -1
  142. package/dist/resources/repo-scope.d.ts +0 -37
  143. package/dist/resources/repo-scope.d.ts.map +0 -1
  144. package/dist/resources/repo-scope.js +0 -92
  145. package/dist/resources/repo-scope.js.map +0 -1
  146. package/dist/resources/rpc-scope.d.ts +0 -31
  147. package/dist/resources/rpc-scope.d.ts.map +0 -1
  148. package/dist/resources/rpc-scope.js +0 -74
  149. package/dist/resources/rpc-scope.js.map +0 -1
  150. package/dist/syntax.d.ts +0 -76
  151. package/dist/syntax.d.ts.map +0 -1
  152. package/dist/syntax.js +0 -249
  153. package/dist/syntax.js.map +0 -1
  154. package/dist/utilities.d.ts +0 -17
  155. package/dist/utilities.d.ts.map +0 -1
  156. package/dist/utilities.js +0 -108
  157. package/dist/utilities.js.map +0 -1
  158. package/src/lib/did.ts +0 -3
  159. package/src/parser.ts +0 -150
  160. package/src/permission-set.ts +0 -78
  161. package/src/resources/account-scope.ts +0 -66
  162. package/src/resources/blob-scope.ts +0 -86
  163. package/src/resources/identity-scope.ts +0 -49
  164. package/src/resources/repo-scope.ts +0 -101
  165. package/src/resources/rpc-scope.test.ts +0 -280
  166. package/src/resources/rpc-scope.ts +0 -77
  167. package/src/syntax.test.ts +0 -203
  168. package/src/syntax.ts +0 -325
  169. package/src/utilities.ts +0 -109
package/dist/parser.js DELETED
@@ -1,118 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Parser = void 0;
4
- exports.knownValuesValidator = knownValuesValidator;
5
- const syntax_js_1 = require("./syntax.js");
6
- class Parser {
7
- constructor(resource, schema, positionalName) {
8
- Object.defineProperty(this, "resource", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: resource
13
- });
14
- Object.defineProperty(this, "schema", {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value: schema
19
- });
20
- Object.defineProperty(this, "positionalName", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: positionalName
25
- });
26
- Object.defineProperty(this, "schemaKeys", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- this.schemaKeys = Object.keys(schema);
33
- }
34
- format(values) {
35
- // Build params
36
- const params = [];
37
- for (const key of this.schemaKeys) {
38
- const value = values[key];
39
- // Ignore undefined values
40
- if (value === undefined)
41
- continue;
42
- const schema = this.schema[key];
43
- // @TODO: when the value is an array, we could remove duplicates
44
- // Normalize the value if a normalization function is provided
45
- const normalized = schema.normalize
46
- ? schema.normalize(value)
47
- : value;
48
- // Ignore values that are equal to the default value
49
- if (!schema.required) {
50
- if (schema.default === normalized)
51
- continue;
52
- if (schema.multiple &&
53
- schema.default &&
54
- arrayParamEquals(schema.default, normalized)) {
55
- continue;
56
- }
57
- }
58
- params.push([key, normalized]);
59
- }
60
- return (0, syntax_js_1.formatScope)(this.resource, params, this.positionalName);
61
- }
62
- parse(syntax) {
63
- if (!syntax.is(this.resource))
64
- return null;
65
- if (syntax.containsParamsOtherThan(this.schemaKeys))
66
- return null;
67
- const result = Object.create(null);
68
- for (const key of this.schemaKeys) {
69
- const definition = this.schema[key];
70
- const value = definition.multiple
71
- ? syntax.getMulti(key, key === this.positionalName)
72
- : syntax.getSingle(key, key === this.positionalName);
73
- if (value === null)
74
- return null; // Value is not valid
75
- if (value === undefined && definition.required)
76
- return null;
77
- if (value !== undefined && definition.validate) {
78
- if (definition.multiple) {
79
- if (!value.every(definition.validate)) {
80
- return null;
81
- }
82
- }
83
- else {
84
- if (!definition.validate(value)) {
85
- return null;
86
- }
87
- }
88
- }
89
- result[key] = value ?? definition.default;
90
- }
91
- return result;
92
- }
93
- parseString(scope) {
94
- const syntax = syntax_js_1.ResourceSyntax.fromString(scope);
95
- return this.parse(syntax);
96
- }
97
- }
98
- exports.Parser = Parser;
99
- /**
100
- * Two param arrays are considered equal if they contain the same values,
101
- * regardless of the order and duplicates.
102
- * @param a - The first array to compare.
103
- * @param b - The second array to compare.
104
- */
105
- function arrayParamEquals(a, b) {
106
- for (const item of a)
107
- if (!b.includes(item))
108
- return false;
109
- for (const item of b)
110
- if (!a.includes(item))
111
- return false;
112
- return true;
113
- }
114
- function knownValuesValidator(values) {
115
- const set = new Set(values);
116
- return (value) => set.has(value);
117
- }
118
- //# sourceMappingURL=parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";;;AAkJA,oDAGC;AArJD,2CAKoB;AAmCpB,MAAa,MAAM;IAGjB,YACW,QAAW,EACX,MAAS,EACT,cAAiC;QAF1C;;;;mBAAS,QAAQ;WAAG;QACpB;;;;mBAAS,MAAM;WAAG;QAClB;;;;mBA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O,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC3B,CAAC;CACF;AAzFD,wBAyFC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CACvB,CAAqB,EACrB,CAAqB;IAErB,KAAK,MAAM,IAAI,IAAI,CAAC;QAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAA;IACzD,KAAK,MAAM,IAAI,IAAI,CAAC;QAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAA;IACzD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAgB,oBAAoB,CAAmB,MAAmB;IACxE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,CAAA;IACnC,OAAO,CAAC,KAAa,EAAc,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACtD,CAAC"}
@@ -1,15 +0,0 @@
1
- import { AccountScopeMatch, BlobScopeMatch, PermissionSet, RepoScopeMatch, RpcScopeMatch } from './permission-set.js';
2
- /**
3
- * Overrides the default permission set to allow transitional scopes to be used
4
- * in place of the generic scopes.
5
- */
6
- export declare class PermissionSetTransition extends PermissionSet {
7
- get hasTransitionGeneric(): boolean;
8
- get hasTransitionEmail(): boolean;
9
- get hasTransitionChatBsky(): boolean;
10
- allowsAccount(options: AccountScopeMatch): boolean;
11
- allowsBlob(options: BlobScopeMatch): boolean;
12
- allowsRepo(options: RepoScopeMatch): boolean;
13
- allowsRpc(options: RpcScopeMatch): boolean;
14
- }
15
- //# sourceMappingURL=permission-set-transition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"permission-set-transition.d.ts","sourceRoot":"","sources":["../src/permission-set-transition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACd,MAAM,qBAAqB,CAAA;AAE5B;;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IAEQ,UAAU,CAAC,OAAuB;QACzC,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC;IAEQ,SAAS,CAAC,OAAsB;QACvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;QAEvB,IAAI,IAAI,CAAC,oBAAoB,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;YAC7C,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,IAAI,CAAC,oBAAoB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,IAAI,CAAC,qBAAqB,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IACjC,CAAC;CACF;AA1DD,0DA0DC"}
@@ -1,22 +0,0 @@
1
- import { AccountScopeMatch } from './resources/account-scope.js';
2
- import { BlobScopeMatch } from './resources/blob-scope.js';
3
- import { IdentityScopeMatch } from './resources/identity-scope.js';
4
- import { RepoScopeMatch } from './resources/repo-scope.js';
5
- import { RpcScopeMatch } from './resources/rpc-scope.js';
6
- import { ScopesSet } from './scopes-set.js';
7
- export type { AccountScopeMatch, BlobScopeMatch, IdentityScopeMatch, RepoScopeMatch, RpcScopeMatch, };
8
- export declare class PermissionSet {
9
- readonly scopes: ScopesSet;
10
- constructor(scopes?: null | string | Iterable<string>);
11
- allowsAccount(options: AccountScopeMatch): boolean;
12
- assertAccount(options: AccountScopeMatch): void;
13
- allowsIdentity(options: IdentityScopeMatch): boolean;
14
- assertIdentity(options: IdentityScopeMatch): void;
15
- allowsBlob(options: BlobScopeMatch): boolean;
16
- assertBlob(options: BlobScopeMatch): void;
17
- allowsRepo(options: RepoScopeMatch): boolean;
18
- assertRepo(options: RepoScopeMatch): void;
19
- allowsRpc(options: RpcScopeMatch): boolean;
20
- assertRpc(options: RpcScopeMatch): void;
21
- }
22
- //# sourceMappingURL=permission-set.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"permission-set.d.ts","sourceRoot":"","sources":["../src/permission-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAa,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAEL,kBAAkB,EACnB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAa,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAY,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,aAAa,GACd,CAAA;AAED,qBAAa,aAAa;IACxB,SAAgB,MAAM,EAAE,SAAS,CAAA;gBAErB,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAM9C,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO;IAGlD,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAO/C,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO;IAGpD,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAOjD,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAG5C,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAOzC,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAG5C,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAOzC,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,O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AAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IACM,UAAU,CAAC,OAAuB;QACvC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,yBAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAC/C,MAAM,IAAI,0CAAiB,CAAC,KAAK,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;IAEM,UAAU,CAAC,OAAuB;QACvC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IACM,UAAU,CAAC,OAAuB;QACvC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,yBAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAC/C,MAAM,IAAI,0CAAiB,CAAC,KAAK,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;IAEM,SAAS,CAAC,OAAsB;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC5C,CAAC;IACM,SAAS,CAAC,OAAsB;QACrC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,uBAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAC9C,MAAM,IAAI,0CAAiB,CAAC,KAAK,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;CACF;AA1DD,sCA0DC"}
@@ -1,35 +0,0 @@
1
- import { Parser } from '../parser.js';
2
- import { ResourceSyntax } from '../syntax.js';
3
- declare const ACCOUNT_ATTRIBUTES: readonly ["email", "repo", "status"];
4
- export type AccountAttribute = (typeof ACCOUNT_ATTRIBUTES)[number];
5
- declare const ACCOUNT_ACTIONS: readonly ["read", "manage"];
6
- export type AccountAction = (typeof ACCOUNT_ACTIONS)[number];
7
- export declare const accountParser: Parser<"account", {
8
- attr: {
9
- multiple: false;
10
- required: true;
11
- validate: (value: string) => value is "email" | "repo" | "status";
12
- };
13
- action: {
14
- multiple: false;
15
- required: false;
16
- validate: (value: string) => value is "read" | "manage";
17
- default: "read";
18
- };
19
- }>;
20
- export type AccountScopeMatch = {
21
- attr: AccountAttribute;
22
- action: AccountAction;
23
- };
24
- export declare class AccountScope {
25
- readonly attr: AccountAttribute;
26
- readonly action: AccountAction;
27
- constructor(attr: AccountAttribute, action: AccountAction);
28
- matches(options: AccountScopeMatch): boolean;
29
- toString(): import("../syntax.js").ScopeForResource<"account">;
30
- static fromString(scope: string): AccountScope | null;
31
- static fromSyntax(syntax: ResourceSyntax): AccountScope | null;
32
- static scopeNeededFor(options: AccountScopeMatch): string;
33
- }
34
- export {};
35
- //# sourceMappingURL=account-scope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account-scope.d.ts","sourceRoot":"","sources":["../../src/resources/account-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAwB,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAsB,MAAM,cAAc,CAAA;AAEjE,QAAA,MAAM,kBAAkB,sCAAsD,CAAA;AAC9E,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAElE,QAAA,MAAM,eAAe,6BAA6C,CAAA;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;AAE5D,eAAO,MAAM,aAAa;;;;;;;;;;;;EAgBzB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,EAAE,aAAa,CAAA;CACtB,CAAA;AAED,qBAAa,YAAY;aAEL,IAAI,EAAE,gBAAgB;aACtB,MAAM,EAAE,aAAa;gBADrB,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,aAAa;IAGvC,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO;IAO5C,QAAQ;IAIR,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM;IAM/B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc;IAOxC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM;CAG1D"}
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccountScope = exports.accountParser = void 0;
4
- const parser_js_1 = require("../parser.js");
5
- const syntax_js_1 = require("../syntax.js");
6
- const ACCOUNT_ATTRIBUTES = Object.freeze(['email', 'repo', 'status']);
7
- const ACCOUNT_ACTIONS = Object.freeze(['read', 'manage']);
8
- exports.accountParser = new parser_js_1.Parser('account', {
9
- attr: {
10
- multiple: false,
11
- required: true,
12
- validate: (0, parser_js_1.knownValuesValidator)(ACCOUNT_ATTRIBUTES),
13
- },
14
- action: {
15
- multiple: false,
16
- required: false,
17
- validate: (0, parser_js_1.knownValuesValidator)(ACCOUNT_ACTIONS),
18
- default: 'read',
19
- },
20
- }, 'attr');
21
- class AccountScope {
22
- constructor(attr, action) {
23
- Object.defineProperty(this, "attr", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: attr
28
- });
29
- Object.defineProperty(this, "action", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: action
34
- });
35
- }
36
- matches(options) {
37
- return (this.attr === options.attr &&
38
- (this.action === 'manage' || this.action === options.action));
39
- }
40
- toString() {
41
- return exports.accountParser.format(this);
42
- }
43
- static fromString(scope) {
44
- if (!(0, syntax_js_1.isScopeForResource)(scope, 'account'))
45
- return null;
46
- const syntax = syntax_js_1.ResourceSyntax.fromString(scope);
47
- return this.fromSyntax(syntax);
48
- }
49
- static fromSyntax(syntax) {
50
- const result = exports.accountParser.parse(syntax);
51
- if (!result)
52
- return null;
53
- return new AccountScope(result.attr, result.action);
54
- }
55
- static scopeNeededFor(options) {
56
- return exports.accountParser.format(options);
57
- }
58
- }
59
- exports.AccountScope = AccountScope;
60
- //# sourceMappingURL=account-scope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account-scope.js","sourceRoot":"","sources":["../../src/resources/account-scope.ts"],"names":[],"mappings":";;;AAAA,4CAA2D;AAC3D,4CAAiE;AAEjE,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC,CAAA;AAG9E,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC,CAAA;AAGrD,QAAA,aAAa,GAAG,IAAI,kBAAM,CACrC,SAAS,EACT;IACE,IAAI,EAAE;QACJ,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAA,gCAAoB,EAAC,kBAAkB,CAAC;KACnD;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,IAAA,gCAAoB,EAAC,eAAe,CAAC;QAC/C,OAAO,EAAE,MAAe;KACzB;CACF,EACD,MAAM,CACP,CAAA;AAOD,MAAa,YAAY;IACvB,YACkB,IAAsB,EACtB,MAAqB;QADrC;;;;mBAAgB,IAAI;WAAkB;QACtC;;;;mBAAgB,MAAM;WAAe;IACpC,CAAC;IAEJ,OAAO,CAAC,OAA0B;QAChC,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI;YAC1B,CAAC,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAC7D,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,qBAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,KAAa;QAC7B,IAAI,CAAC,IAAA,8BAAkB,EAAC,KAAK,EAAE,SAAS,CAAC;YAAE,OAAO,IAAI,CAAA;QACtD,MAAM,MAAM,GAAG,0BAAc,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAC/C,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAsB;QACtC,MAAM,MAAM,GAAG,qBAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAA;QAExB,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACrD,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,OAA0B;QAC9C,OAAO,qBAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACtC,CAAC;CACF;AAjCD,oCAiCC"}
@@ -1,25 +0,0 @@
1
- import { Accept, isAccept } from '../lib/mime.js';
2
- import { Parser } from '../parser.js';
3
- import { NeRoArray, ResourceSyntax } from '../syntax.js';
4
- export declare const DEFAULT_ACCEPT: readonly ["*/*"];
5
- export declare const blobParser: Parser<"blob", {
6
- accept: {
7
- multiple: true;
8
- required: true;
9
- validate: typeof isAccept;
10
- normalize: (value: NeRoArray<string>) => readonly ["*/*"] | [Accept, ...Accept[]];
11
- };
12
- }>;
13
- export type BlobScopeMatch = {
14
- mime: string;
15
- };
16
- export declare class BlobScope {
17
- readonly accept: NeRoArray<Accept>;
18
- constructor(accept: NeRoArray<Accept>);
19
- matches(options: BlobScopeMatch): boolean;
20
- toString(): import("../syntax.js").ScopeForResource<"blob">;
21
- static fromString(scope: string): BlobScope | null;
22
- static fromSyntax(syntax: ResourceSyntax): BlobScope | null;
23
- static scopeNeededFor(options: BlobScopeMatch): import("../syntax.js").ScopeForResource<"blob">;
24
- }
25
- //# sourceMappingURL=blob-scope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blob-scope.d.ts","sourceRoot":"","sources":["../../src/resources/blob-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAoB,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAsB,MAAM,cAAc,CAAA;AAE5E,eAAO,MAAM,cAAc,kBAAkC,CAAA;AAE7D,eAAO,MAAM,UAAU;;;;;;;EAmBtB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,qBAAa,SAAS;aACQ,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC;gBAAzB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC;IAErD,OAAO,CAAC,OAAO,EAAE,cAAc;IAI/B,QAAQ;IAIR,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM;IAM/B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc;IAOxC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc;CAK9C"}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlobScope = exports.blobParser = exports.DEFAULT_ACCEPT = void 0;
4
- const mime_js_1 = require("../lib/mime.js");
5
- const parser_js_1 = require("../parser.js");
6
- const syntax_js_1 = require("../syntax.js");
7
- exports.DEFAULT_ACCEPT = Object.freeze(['*/*']);
8
- exports.blobParser = new parser_js_1.Parser('blob', {
9
- accept: {
10
- multiple: true,
11
- required: true,
12
- validate: mime_js_1.isAccept,
13
- normalize: (value) => {
14
- // Returns a more concise representation of the accept values.
15
- if (value.includes('*/*'))
16
- return exports.DEFAULT_ACCEPT;
17
- return value.map(toLowerCase).filter(isNonRedundant);
18
- },
19
- },
20
- }, 'accept');
21
- class BlobScope {
22
- constructor(accept) {
23
- Object.defineProperty(this, "accept", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: accept
28
- });
29
- }
30
- matches(options) {
31
- return (0, mime_js_1.matchesAnyAccept)(this.accept, options.mime);
32
- }
33
- toString() {
34
- return exports.blobParser.format(this);
35
- }
36
- static fromString(scope) {
37
- if (!(0, syntax_js_1.isScopeForResource)(scope, 'blob'))
38
- return null;
39
- const syntax = syntax_js_1.ResourceSyntax.fromString(scope);
40
- return this.fromSyntax(syntax);
41
- }
42
- static fromSyntax(syntax) {
43
- const result = exports.blobParser.parse(syntax);
44
- if (!result)
45
- return null;
46
- return new BlobScope(result.accept);
47
- }
48
- static scopeNeededFor(options) {
49
- return exports.blobParser.format({
50
- accept: [options.mime],
51
- });
52
- }
53
- }
54
- exports.BlobScope = BlobScope;
55
- function toLowerCase(value) {
56
- return value.toLowerCase();
57
- }
58
- function isNonRedundant(value, index, arr) {
59
- if (value.endsWith('/*')) {
60
- // assuming the array contains unique element, wildcards cannot be redundant
61
- // with one another ('image/*' is not redundant with 'text/*')
62
- return true;
63
- }
64
- const base = value.split('/', 1)[0];
65
- if (arr.includes(`${base}/*`)) {
66
- // If another value in the array is a wildcard for the same base, we can
67
- // skip this one as it is redundant. e.g. if the array contains 'image/png'
68
- // and 'image/*', we can skip 'image/png' because 'image/*' already covers
69
- // it.
70
- return false;
71
- }
72
- return true;
73
- }
74
- //# sourceMappingURL=blob-scope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blob-scope.js","sourceRoot":"","sources":["../../src/resources/blob-scope.ts"],"names":[],"mappings":";;;AAAA,4CAAmE;AACnE,4CAAqC;AACrC,4CAA4E;AAE/D,QAAA,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAU,CAAC,CAAA;AAEhD,QAAA,UAAU,GAAG,IAAI,kBAAM,CAClC,MAAM,EACN;IACE,MAAM,EAAE;QACN,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AAC,CAAA;IACJ,CAAC;CACF;AA7BD,8BA6BC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;AAC5B,CAAC;AAED,SAAS,cAAc,CACrB,KAAa,EACb,KAAa,EACb,GAAsB;IAEtB,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,4EAA4E;QAC5E,8DAA8D;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;QAC9B,wEAAwE;QACxE,2EAA2E;QAC3E,0EAA0E;QAC1E,MAAM;QACN,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -1,25 +0,0 @@
1
- import { Parser } from '../parser.js';
2
- import { ResourceSyntax } from '../syntax.js';
3
- declare const IDENTITY_ATTRIBUTES: readonly ["handle", "*"];
4
- export type IdentityAttribute = (typeof IDENTITY_ATTRIBUTES)[number];
5
- export declare const identityParser: Parser<"identity", {
6
- attr: {
7
- multiple: false;
8
- required: true;
9
- validate: (value: string) => value is "*" | "handle";
10
- };
11
- }>;
12
- export type IdentityScopeMatch = {
13
- attr: IdentityAttribute;
14
- };
15
- export declare class IdentityScope {
16
- readonly attr: IdentityAttribute;
17
- constructor(attr: IdentityAttribute);
18
- matches(options: IdentityScopeMatch): boolean;
19
- toString(): import("../syntax.js").ScopeForResource<"identity">;
20
- static fromString(scope: string): IdentityScope | null;
21
- static fromSyntax(syntax: ResourceSyntax): IdentityScope | null;
22
- static scopeNeededFor(options: IdentityScopeMatch): string;
23
- }
24
- export {};
25
- //# sourceMappingURL=identity-scope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity-scope.d.ts","sourceRoot":"","sources":["../../src/resources/identity-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAwB,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAsB,MAAM,cAAc,CAAA;AAEjE,QAAA,MAAM,mBAAmB,0BAA0C,CAAA;AACnE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpE,eAAO,MAAM,cAAc;;;;;;EAU1B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,iBAAiB,CAAA;CACxB,CAAA;AAED,qBAAa,aAAa;aACI,IAAI,EAAE,iBAAiB;gBAAvB,IAAI,EAAE,iBAAiB;IAEnD,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO;IAI7C,QAAQ;IAIR,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM;IAM/B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc;IAMxC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM;CAG3D"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IdentityScope = exports.identityParser = void 0;
4
- const parser_js_1 = require("../parser.js");
5
- const syntax_js_1 = require("../syntax.js");
6
- const IDENTITY_ATTRIBUTES = Object.freeze(['handle', '*']);
7
- exports.identityParser = new parser_js_1.Parser('identity', {
8
- attr: {
9
- multiple: false,
10
- required: true,
11
- validate: (0, parser_js_1.knownValuesValidator)(IDENTITY_ATTRIBUTES),
12
- },
13
- }, 'attr');
14
- class IdentityScope {
15
- constructor(attr) {
16
- Object.defineProperty(this, "attr", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: attr
21
- });
22
- }
23
- matches(options) {
24
- return this.attr === '*' || this.attr === options.attr;
25
- }
26
- toString() {
27
- return exports.identityParser.format(this);
28
- }
29
- static fromString(scope) {
30
- if (!(0, syntax_js_1.isScopeForResource)(scope, 'identity'))
31
- return null;
32
- const syntax = syntax_js_1.ResourceSyntax.fromString(scope);
33
- return this.fromSyntax(syntax);
34
- }
35
- static fromSyntax(syntax) {
36
- const result = exports.identityParser.parse(syntax);
37
- if (!result)
38
- return null;
39
- return new IdentityScope(result.attr);
40
- }
41
- static scopeNeededFor(options) {
42
- return exports.identityParser.format(options);
43
- }
44
- }
45
- exports.IdentityScope = IdentityScope;
46
- //# sourceMappingURL=identity-scope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity-scope.js","sourceRoot":"","sources":["../../src/resources/identity-scope.ts"],"names":[],"mappings":";;;AAAA,4CAA2D;AAC3D,4CAAiE;AAEjE,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAU,CAAC,CAAA;AAGtD,QAAA,cAAc,GAAG,IAAI,kBAAM,CACtC,UAAU,EACV;IACE,IAAI,EAAE;QACJ,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAA,gCAAoB,EAAC,mBAAmB,CAAC;KACpD;CACF,EACD,MAAM,CACP,CAAA;AAMD,MAAa,aAAa;IACxB,YAA4B,IAAuB;QAAvC;;;;mBAAgB,IAAI;WAAmB;IAAG,CAAC;IAEvD,OAAO,CAAC,OAA2B;QACjC,OAAO,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAA;IACxD,CAAC;IAED,QAAQ;QACN,OAAO,sBAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,KAAa;QAC7B,IAAI,CAAC,IAAA,8BAAkB,EAAC,KAAK,EAAE,UAAU,CAAC;YAAE,OAAO,IAAI,CAAA;QACvD,MAAM,MAAM,GAAG,0BAAc,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAC/C,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAsB;QACtC,MAAM,MAAM,GAAG,sBAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAC3C,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAA;QACxB,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,OAA2B;QAC/C,OAAO,sBAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;CACF;AA1BD,sCA0BC"}
@@ -1,37 +0,0 @@
1
- import { NSID } from '../lib/nsid.js';
2
- import { Parser } from '../parser.js';
3
- import { NeRoArray, ResourceSyntax } from '../syntax.js';
4
- declare const REPO_ACTIONS: readonly ["create", "update", "delete"];
5
- export type RepoAction = (typeof REPO_ACTIONS)[number];
6
- export declare const isRepoAction: (value: string) => value is "delete" | "create" | "update";
7
- export declare const repoParser: Parser<"repo", {
8
- collection: {
9
- multiple: true;
10
- required: true;
11
- validate: (value: string) => value is "*" | `${string}.${string}`;
12
- normalize: (value: NeRoArray<string>) => NeRoArray<string>;
13
- };
14
- action: {
15
- multiple: true;
16
- required: false;
17
- validate: (value: string) => value is "delete" | "create" | "update";
18
- default: readonly ["create", "update", "delete"];
19
- };
20
- }>;
21
- export type RepoScopeMatch = {
22
- collection: string;
23
- action: RepoAction;
24
- };
25
- export declare class RepoScope {
26
- readonly collection: NeRoArray<'*' | NSID>;
27
- readonly action: NeRoArray<RepoAction>;
28
- constructor(collection: NeRoArray<'*' | NSID>, action: NeRoArray<RepoAction>);
29
- get allowsAnyCollection(): boolean;
30
- matches({ action, collection }: RepoScopeMatch): boolean;
31
- toString(): string;
32
- static fromString(scope: string): RepoScope | null;
33
- static fromSyntax(syntax: ResourceSyntax): RepoScope | null;
34
- static scopeNeededFor(options: RepoScopeMatch): string;
35
- }
36
- export {};
37
- //# sourceMappingURL=repo-scope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repo-scope.d.ts","sourceRoot":"","sources":["../../src/resources/repo-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAwB,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAsB,MAAM,cAAc,CAAA;AAE5E,QAAA,MAAM,YAAY,yCAAyD,CAAA;AAC3E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AACtD,eAAO,MAAM,YAAY,4DAAqC,CAAA;AAE9D,eAAO,MAAM,UAAU;;;;;;;;;;;;;EAoBtB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,UAAU,CAAA;CACnB,CAAA;AAED,qBAAa,SAAS;aAEF,UAAU,EAAE,SAAS,CAAC,GAAG,GAAG,IAAI,CAAC;aACjC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC;gBAD7B,UAAU,EAAE,SAAS,CAAC,GAAG,GAAG,IAAI,CAAC,EACjC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC;IAG/C,IAAI,mBAAmB,YAEtB;IAED,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,cAAc,GAAG,OAAO;IAQxD,QAAQ,IAAI,MAAM;IAkBlB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAMlD,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI;IAO3D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM;CAMvD"}
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RepoScope = exports.repoParser = exports.isRepoAction = void 0;
4
- const nsid_js_1 = require("../lib/nsid.js");
5
- const parser_js_1 = require("../parser.js");
6
- const syntax_js_1 = require("../syntax.js");
7
- const REPO_ACTIONS = Object.freeze(['create', 'update', 'delete']);
8
- exports.isRepoAction = (0, parser_js_1.knownValuesValidator)(REPO_ACTIONS);
9
- exports.repoParser = new parser_js_1.Parser('repo', {
10
- collection: {
11
- multiple: true,
12
- required: true,
13
- validate: (value) => value === '*' || (0, nsid_js_1.isNSID)(value),
14
- normalize: (value) => {
15
- if (value.length > 1 && value.includes('*'))
16
- return ['*'];
17
- return value;
18
- },
19
- },
20
- action: {
21
- multiple: true,
22
- required: false,
23
- validate: exports.isRepoAction,
24
- default: REPO_ACTIONS,
25
- },
26
- }, 'collection');
27
- class RepoScope {
28
- constructor(collection, action) {
29
- Object.defineProperty(this, "collection", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: collection
34
- });
35
- Object.defineProperty(this, "action", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: action
40
- });
41
- }
42
- get allowsAnyCollection() {
43
- return this.collection.includes('*');
44
- }
45
- matches({ action, collection }) {
46
- return (this.action.includes(action) &&
47
- (this.allowsAnyCollection ||
48
- this.collection.includes(collection)));
49
- }
50
- toString() {
51
- // Normalize (compress, de-dupe, sort)
52
- return exports.repoParser.format({
53
- collection: this.allowsAnyCollection
54
- ? ['*']
55
- : this.collection.length > 1
56
- ? [...new Set(this.collection)].sort()
57
- : this.collection,
58
- action: this.action === REPO_ACTIONS
59
- ? REPO_ACTIONS // No need to filter if the default was used
60
- : REPO_ACTIONS.filter(includedIn, this.action),
61
- });
62
- }
63
- static fromString(scope) {
64
- if (!(0, syntax_js_1.isScopeForResource)(scope, 'repo'))
65
- return null;
66
- const syntax = syntax_js_1.ResourceSyntax.fromString(scope);
67
- return this.fromSyntax(syntax);
68
- }
69
- static fromSyntax(syntax) {
70
- const result = exports.repoParser.parse(syntax);
71
- if (!result)
72
- return null;
73
- return new RepoScope(result.collection, result.action);
74
- }
75
- static scopeNeededFor(options) {
76
- return exports.repoParser.format({
77
- collection: [options.collection],
78
- action: [options.action],
79
- });
80
- }
81
- }
82
- exports.RepoScope = RepoScope;
83
- /**
84
- * Special utility function to be used as predicate for array methods like
85
- * `Array.prototype.includes`, etc. When used as predicate, it expects that
86
- * the array method is called with a `thisArg` that is a readonly array of
87
- * the same type as the `value` parameter.
88
- */
89
- function includedIn(value) {
90
- return this.includes(value);
91
- }
92
- //# sourceMappingURL=repo-scope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repo-scope.js","sourceRoot":"","sources":["../../src/resources/repo-scope.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAC7C,4CAA2D;AAC3D,4CAA4E;AAE5E,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC,CAAA;AAE9D,QAAA,YAAY,GAAG,IAAA,gCAAoB,EAAC,YAAY,CAAC,CAAA;AAEjD,QAAA,UAAU,GAAG,IAAI,kBAAM,CAClC,MAAM,EACN;IACE,UAAU,EAAE;QACV,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,GAAG,IAAI,IAAA,gBAAM,EAAC,KAAK,CAAC;QACnD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACnB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAU,CAAA;YAClE,OAAO,KAAK,CAAA;QACd,CAAC;KACF;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,oBAAY;QACtB,OAAO,EAAE,YAA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