@naturalcycles/abba 1.1.0 → 1.5.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 (42) hide show
  1. package/dist/abba.d.ts +2 -2
  2. package/dist/abba.js +11 -5
  3. package/dist/index.d.ts +1 -1
  4. package/dist/prisma-output/index-browser.js +141 -0
  5. package/dist/prisma-output/index.d.ts +5521 -0
  6. package/dist/prisma-output/index.js +192 -0
  7. package/dist/prisma-output/libquery_engine-darwin.dylib.node +0 -0
  8. package/dist/prisma-output/libquery_engine-debian-openssl-1.1.x.so.node +0 -0
  9. package/dist/prisma-output/runtime/esm/index-browser.mjs +2370 -0
  10. package/dist/prisma-output/runtime/esm/index.mjs +40587 -0
  11. package/dist/prisma-output/runtime/esm/proxy.mjs +113 -0
  12. package/dist/prisma-output/runtime/index-browser.d.ts +269 -0
  13. package/dist/prisma-output/runtime/index-browser.js +2621 -0
  14. package/dist/prisma-output/runtime/index.d.ts +1373 -0
  15. package/dist/prisma-output/runtime/index.js +52855 -0
  16. package/dist/prisma-output/runtime/proxy.d.ts +1373 -0
  17. package/dist/prisma-output/runtime/proxy.js +13717 -0
  18. package/dist/prisma-output/schema.prisma +47 -0
  19. package/dist/types.d.ts +1 -1
  20. package/dist/util.d.ts +7 -14
  21. package/dist/util.js +18 -29
  22. package/package.json +5 -6
  23. package/readme.md +18 -14
  24. package/src/abba.ts +13 -13
  25. package/src/index.ts +1 -1
  26. package/src/prisma-output/index-browser.js +141 -0
  27. package/src/prisma-output/index.d.ts +5521 -0
  28. package/src/prisma-output/index.js +192 -0
  29. package/src/prisma-output/libquery_engine-darwin.dylib.node +0 -0
  30. package/src/prisma-output/libquery_engine-debian-openssl-1.1.x.so.node +0 -0
  31. package/src/prisma-output/runtime/esm/index-browser.mjs +2370 -0
  32. package/src/prisma-output/runtime/esm/index.mjs +40587 -0
  33. package/src/prisma-output/runtime/esm/proxy.mjs +113 -0
  34. package/src/prisma-output/runtime/index-browser.d.ts +269 -0
  35. package/src/prisma-output/runtime/index-browser.js +2621 -0
  36. package/src/prisma-output/runtime/index.d.ts +1373 -0
  37. package/src/prisma-output/runtime/index.js +52855 -0
  38. package/src/prisma-output/runtime/proxy.d.ts +1373 -0
  39. package/src/prisma-output/runtime/proxy.js +13717 -0
  40. package/src/prisma-output/schema.prisma +47 -0
  41. package/src/types.ts +1 -1
  42. package/src/util.ts +12 -20
package/dist/abba.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { UserAssignment } from '../prisma/generated/output';
1
+ import { UserAssignment } from './prisma-output';
2
2
  import { BucketInput, ExperimentWithBuckets, ExperimentInput, SegmentationData, AssignmentStatistics } from '.';
3
3
  export declare class Abba {
4
4
  private client;
5
- constructor();
5
+ constructor(dbUrl?: string);
6
6
  /**
7
7
  * Returns all experiments
8
8
  *
package/dist/abba.js CHANGED
@@ -1,15 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Abba = void 0;
4
- const output_1 = require("../prisma/generated/output");
4
+ const prisma_output_1 = require("./prisma-output");
5
5
  const types_1 = require("./types");
6
6
  const util_1 = require("./util");
7
7
  // Note: Schema currently contains an output dir which generates all the files to the prisma dir
8
8
  // it would be tidier not to include it here when possible later on:
9
9
  // Explanation is here: https://github.com/prisma/prisma/issues/9435#issuecomment-960290681
10
10
  class Abba {
11
- constructor() {
12
- this.client = new output_1.PrismaClient();
11
+ constructor(dbUrl) {
12
+ this.client = new prisma_output_1.PrismaClient({
13
+ datasources: {
14
+ db: {
15
+ url: dbUrl,
16
+ },
17
+ },
18
+ });
13
19
  }
14
20
  /**
15
21
  * Returns all experiments
@@ -31,7 +37,7 @@ class Abba {
31
37
  */
32
38
  async createExperiment(experiment, buckets) {
33
39
  if (experiment.status === types_1.AssignmentStatus.Active) {
34
- (0, util_1.validateBuckets)(buckets);
40
+ (0, util_1.validateTotalBucketRatio)(buckets);
35
41
  }
36
42
  const created = await this.client.experiment.create({
37
43
  data: {
@@ -60,7 +66,7 @@ class Abba {
60
66
  */
61
67
  async saveExperiment(id, experiment, buckets) {
62
68
  if (experiment.status === types_1.AssignmentStatus.Active) {
63
- (0, util_1.validateBuckets)(buckets);
69
+ (0, util_1.validateTotalBucketRatio)(buckets);
64
70
  }
65
71
  const updatedExperiment = await this.updateExperiment(id, experiment);
66
72
  const updatedBuckets = await this.saveBuckets(buckets);
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export type { Bucket, Experiment, UserAssignment } from '../prisma/generated/output';
1
+ export type { Bucket, Experiment, UserAssignment } from './prisma-output';
2
2
  export * from './types';
3
3
  export { Abba } from './abba';
@@ -0,0 +1,141 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true })
2
+
3
+ const { Decimal } = require('./runtime/index-browser')
4
+
5
+ const Prisma = {}
6
+
7
+ exports.Prisma = Prisma
8
+
9
+ /**
10
+ * Prisma Client JS version: 3.9.2
11
+ * Query Engine version: bcc2ff906db47790ee902e7bbc76d7ffb1893009
12
+ */
13
+ Prisma.prismaVersion = {
14
+ client: '3.9.2',
15
+ engine: 'bcc2ff906db47790ee902e7bbc76d7ffb1893009',
16
+ }
17
+
18
+ Prisma.PrismaClientKnownRequestError = () => {
19
+ throw new Error(`PrismaClientKnownRequestError is unable to be run in the browser.
20
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
21
+ }
22
+ Prisma.PrismaClientUnknownRequestError = () => {
23
+ throw new Error(`PrismaClientUnknownRequestError is unable to be run in the browser.
24
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
25
+ }
26
+ Prisma.PrismaClientRustPanicError = () => {
27
+ throw new Error(`PrismaClientRustPanicError is unable to be run in the browser.
28
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
29
+ }
30
+ Prisma.PrismaClientInitializationError = () => {
31
+ throw new Error(`PrismaClientInitializationError is unable to be run in the browser.
32
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
33
+ }
34
+ Prisma.PrismaClientValidationError = () => {
35
+ throw new Error(`PrismaClientValidationError is unable to be run in the browser.
36
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
37
+ }
38
+ Prisma.Decimal = Decimal
39
+
40
+ /**
41
+ * Re-export of sql-template-tag
42
+ */
43
+ Prisma.sql = () => {
44
+ throw new Error(`sqltag is unable to be run in the browser.
45
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
46
+ }
47
+ Prisma.empty = () => {
48
+ throw new Error(`empty is unable to be run in the browser.
49
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
50
+ }
51
+ Prisma.join = () => {
52
+ throw new Error(`join is unable to be run in the browser.
53
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
54
+ }
55
+ Prisma.raw = () => {
56
+ throw new Error(`raw is unable to be run in the browser.
57
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)
58
+ }
59
+ Prisma.validator = () => val => val
60
+
61
+ /**
62
+ * Shorthand utilities for JSON filtering
63
+ */
64
+ Prisma.DbNull = 'DbNull'
65
+ Prisma.JsonNull = 'JsonNull'
66
+ Prisma.AnyNull = 'AnyNull'
67
+
68
+ /**
69
+ * Enums
70
+ */
71
+ // Based on
72
+ // https://github.com/microsoft/TypeScript/issues/3192#issuecomment-261720275
73
+ function makeEnum(x) {
74
+ return x
75
+ }
76
+
77
+ exports.Prisma.BucketScalarFieldEnum = makeEnum({
78
+ id: 'id',
79
+ experimentId: 'experimentId',
80
+ key: 'key',
81
+ ratio: 'ratio',
82
+ createdAt: 'createdAt',
83
+ updatedAt: 'updatedAt',
84
+ })
85
+
86
+ exports.Prisma.ExperimentScalarFieldEnum = makeEnum({
87
+ id: 'id',
88
+ name: 'name',
89
+ status: 'status',
90
+ sampling: 'sampling',
91
+ createdAt: 'createdAt',
92
+ updatedAt: 'updatedAt',
93
+ description: 'description',
94
+ rules: 'rules',
95
+ })
96
+
97
+ exports.Prisma.UserAssignmentScalarFieldEnum = makeEnum({
98
+ id: 'id',
99
+ userId: 'userId',
100
+ experimentId: 'experimentId',
101
+ bucketId: 'bucketId',
102
+ createdAt: 'createdAt',
103
+ updatedAt: 'updatedAt',
104
+ })
105
+
106
+ exports.Prisma.SortOrder = makeEnum({
107
+ asc: 'asc',
108
+ desc: 'desc',
109
+ })
110
+
111
+ exports.Prisma.NullableJsonNullValueInput = makeEnum({
112
+ DbNull: 'DbNull',
113
+ JsonNull: 'JsonNull',
114
+ })
115
+
116
+ exports.Prisma.JsonNullValueFilter = makeEnum({
117
+ DbNull: 'DbNull',
118
+ JsonNull: 'JsonNull',
119
+ AnyNull: 'AnyNull',
120
+ })
121
+
122
+ exports.Prisma.ModelName = makeEnum({
123
+ Bucket: 'Bucket',
124
+ Experiment: 'Experiment',
125
+ UserAssignment: 'UserAssignment',
126
+ })
127
+
128
+ /**
129
+ * Create the Client
130
+ */
131
+ class PrismaClient {
132
+ constructor() {
133
+ throw new Error(
134
+ `PrismaClient is unable to be run in the browser.
135
+ In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
136
+ )
137
+ }
138
+ }
139
+ exports.PrismaClient = PrismaClient
140
+
141
+ Object.assign(exports, Prisma)