@dxos/effect 0.8.4-main.422d1c7879 → 0.8.4-main.4668b7de9b

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/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
package/README.md CHANGED
@@ -12,4 +12,4 @@ pnpm i @dxos/effect
12
12
 
13
13
  Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
14
14
 
15
- License: [MIT](./LICENSE) Copyright 2022 © DXOS
15
+ License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
@@ -10,7 +10,6 @@ import * as Schema from "effect/Schema";
10
10
  import * as SchemaAST from "effect/SchemaAST";
11
11
  import { invariant } from "@dxos/invariant";
12
12
  import { isNonNullable } from "@dxos/util";
13
- var __dxlog_file = "/__w/dxos/dxos/packages/common/effect/src/ast.ts";
14
13
  var reduceRefinements = (type, refinements = []) => {
15
14
  if (SchemaAST.isRefinement(type)) {
16
15
  const filter = type.filter;
@@ -151,15 +150,7 @@ var findProperty = (schema, path) => {
151
150
  const getProp = (node, path2) => {
152
151
  const [name, ...rest] = path2;
153
152
  const typeNode = findNode(node, SchemaAST.isTypeLiteral);
154
- invariant(typeNode, void 0, {
155
- F: __dxlog_file,
156
- L: 247,
157
- S: void 0,
158
- A: [
159
- "typeNode",
160
- ""
161
- ]
162
- });
153
+ invariant(typeNode);
163
154
  for (const prop of SchemaAST.getPropertySignatures(typeNode)) {
164
155
  if (prop.name === name) {
165
156
  if (rest.length) {
@@ -207,6 +198,12 @@ var isOption = (node) => {
207
198
  var isLiteralUnion = (node) => {
208
199
  return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);
209
200
  };
201
+ var getLiteralValues = (schema) => {
202
+ if (!isLiteralUnion(schema.ast)) {
203
+ return [];
204
+ }
205
+ return schema.ast.types.map((node) => node.literal);
206
+ };
210
207
  var isArrayType = (node) => {
211
208
  return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;
212
209
  };
@@ -220,15 +217,7 @@ var isDiscriminatedUnion = (node) => {
220
217
  return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
221
218
  };
222
219
  var getDiscriminatingProps = (node) => {
223
- invariant(SchemaAST.isUnion(node), void 0, {
224
- F: __dxlog_file,
225
- L: 365,
226
- S: void 0,
227
- A: [
228
- "SchemaAST.isUnion(node)",
229
- ""
230
- ]
231
- });
220
+ invariant(SchemaAST.isUnion(node));
232
221
  if (isOption(node)) {
233
222
  return;
234
223
  }
@@ -238,39 +227,15 @@ var getDiscriminatingProps = (node) => {
238
227
  }, []);
239
228
  };
240
229
  var getDiscriminatedType = (node, value = {}) => {
241
- invariant(SchemaAST.isUnion(node), void 0, {
242
- F: __dxlog_file,
243
- L: 389,
244
- S: void 0,
245
- A: [
246
- "SchemaAST.isUnion(node)",
247
- ""
248
- ]
249
- });
250
- invariant(value, void 0, {
251
- F: __dxlog_file,
252
- L: 390,
253
- S: void 0,
254
- A: [
255
- "value",
256
- ""
257
- ]
258
- });
230
+ invariant(SchemaAST.isUnion(node));
231
+ invariant(value);
259
232
  const props = getDiscriminatingProps(node);
260
233
  if (!props?.length) {
261
234
  return;
262
235
  }
263
236
  for (const type of node.types) {
264
237
  const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
265
- invariant(SchemaAST.isLiteral(prop.type), void 0, {
266
- F: __dxlog_file,
267
- L: 401,
268
- S: void 0,
269
- A: [
270
- "SchemaAST.isLiteral(prop.type)",
271
- ""
272
- ]
273
- });
238
+ invariant(SchemaAST.isLiteral(prop.type));
274
239
  return prop.type.literal === value[prop.name.toString()];
275
240
  });
276
241
  if (match) {
@@ -280,15 +245,7 @@ var getDiscriminatedType = (node, value = {}) => {
280
245
  const fields = Object.fromEntries(props.map((prop) => {
281
246
  const literals = node.types.map((type) => {
282
247
  const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
283
- invariant(SchemaAST.isLiteral(literal.type), void 0, {
284
- F: __dxlog_file,
285
- L: 419,
286
- S: void 0,
287
- A: [
288
- "SchemaAST.isLiteral(literal.type)",
289
- ""
290
- ]
291
- });
248
+ invariant(SchemaAST.isLiteral(literal.type));
292
249
  return literal.type.literal;
293
250
  }).filter(isNonNullable);
294
251
  return literals.length ? [
@@ -356,12 +313,8 @@ var createKvsStore = (options) => {
356
313
  // src/context.ts
357
314
  import * as Effect from "effect/Effect";
358
315
  import { Context } from "@dxos/context";
359
- var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
360
316
  var contextFromScope = () => Effect.gen(function* () {
361
- const ctx = new Context(void 0, {
362
- F: __dxlog_file2,
363
- L: 13
364
- });
317
+ const ctx = new Context();
365
318
  yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
366
319
  return ctx;
367
320
  });
@@ -629,7 +582,6 @@ import * as Schema2 from "effect/Schema";
629
582
  import { JSONPath } from "jsonpath-plus";
630
583
  import { invariant as invariant2 } from "@dxos/invariant";
631
584
  import { getDeep, setDeep } from "@dxos/util";
632
- var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/json-path.ts";
633
585
  var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
634
586
  var PROP_REGEX = /^\w+$/;
635
587
  var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
@@ -650,28 +602,12 @@ var createJsonPath = (path) => {
650
602
  return i === 0 ? p : `.${p}`;
651
603
  }
652
604
  }).join("");
653
- invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
654
- F: __dxlog_file3,
655
- L: 69,
656
- S: void 0,
657
- A: [
658
- "isJsonPath(candidatePath)",
659
- "`Invalid JsonPath: ${candidatePath}`"
660
- ]
661
- });
605
+ invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);
662
606
  return candidatePath;
663
607
  };
664
608
  var fromEffectValidationPath = (effectPath) => {
665
609
  const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
666
- invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
667
- F: __dxlog_file3,
668
- L: 80,
669
- S: void 0,
670
- A: [
671
- "isJsonPath(jsonPath)",
672
- "`Invalid JsonPath: ${jsonPath}`"
673
- ]
674
- });
610
+ invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);
675
611
  return jsonPath;
676
612
  };
677
613
  var splitJsonPath = (path) => {
@@ -826,9 +762,13 @@ var asyncTaskTaggingLayer = () => {
826
762
  },
827
763
  context: (f, fiber) => {
828
764
  const maybeParentSpan = Context3.getOption(Tracer.ParentSpan)(fiber.currentContext);
829
- if (maybeParentSpan._tag === "None") return oldTracer.context(f, fiber);
765
+ if (maybeParentSpan._tag === "None") {
766
+ return oldTracer.context(f, fiber);
767
+ }
830
768
  const parentSpan = maybeParentSpan.value;
831
- if (parentSpan._tag === "ExternalSpan") return oldTracer.context(f, fiber);
769
+ if (parentSpan._tag === "ExternalSpan") {
770
+ return oldTracer.context(f, fiber);
771
+ }
832
772
  const span = parentSpan;
833
773
  if (runInTask in span && typeof span[runInTask] === "function") {
834
774
  return span[runInTask](() => oldTracer.context(f, fiber));
@@ -864,6 +804,7 @@ export {
864
804
  getDiscriminatedType,
865
805
  getDiscriminatingProps,
866
806
  getField,
807
+ getLiteralValues,
867
808
  getParamKeyAnnotation,
868
809
  getProperties,
869
810
  getValue,