@intelligo-dev/core 1.0.0-beta.13 → 1.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/db/schema/billing.d.ts +207 -2
- package/dist/db/schema/billing.d.ts.map +1 -1
- package/dist/db/schema/billing.js +32 -3
- package/dist/db/schema/billing.js.map +1 -1
- package/dist/identity/index.d.ts +4 -3
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +3 -2
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/service.d.ts +20 -4
- package/dist/identity/service.d.ts.map +1 -1
- package/dist/identity/service.js +78 -3
- package/dist/identity/service.js.map +1 -1
- package/dist/identity/types.d.ts +28 -1
- package/dist/identity/types.d.ts.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/types.d.ts +8 -1
- package/dist/notifications/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/db/migrations/0003_local_payments.sql +18 -0
- package/src/db/migrations/README.md +31 -2
- package/src/db/migrations/legacy-chain.json +13 -4
- package/src/db/migrations/meta/0003_snapshot.json +4501 -0
- package/src/db/migrations/meta/_journal.json +7 -0
- package/src/db/schema/billing.ts +39 -3
- package/src/identity/index.ts +4 -1
- package/src/identity/service.ts +106 -5
- package/src/identity/types.ts +30 -0
- package/src/notifications/index.ts +5 -1
- package/src/notifications/types.ts +9 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plans, subscriptions, credit ledgers, purchases
|
|
3
|
-
* Amounts in the credit ledgers are micros of their
|
|
2
|
+
* Plans, subscriptions, credit ledgers, purchases, local payments and
|
|
3
|
+
* Stripe events. Amounts in the credit ledgers are micros of their
|
|
4
|
+
* currency; amounts a buyer paid are minor units of theirs.
|
|
4
5
|
*/
|
|
5
6
|
/**
|
|
6
7
|
* The registered plan catalogue, copied into rows so a subscription can
|
|
@@ -865,6 +866,208 @@ export declare const creditPurchases: import("drizzle-orm/pg-core").PgTableWithC
|
|
|
865
866
|
};
|
|
866
867
|
dialect: "pg";
|
|
867
868
|
}>;
|
|
869
|
+
/**
|
|
870
|
+
* Invoices issued through a registered payment provider (QR-and-poll
|
|
871
|
+
* methods such as QPay, PIX or UPI), one row per invoice. The row is
|
|
872
|
+
* written when the invoice is opened, so settlement knows who pays and
|
|
873
|
+
* what was priced without trusting the browser; `fulfilled_at` is set
|
|
874
|
+
* in the same transaction that grants what was bought, so a payment is
|
|
875
|
+
* granted once however many polls see it paid.
|
|
876
|
+
*/
|
|
877
|
+
export declare const payments: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
878
|
+
name: "payments";
|
|
879
|
+
schema: undefined;
|
|
880
|
+
columns: {
|
|
881
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
882
|
+
name: "id";
|
|
883
|
+
tableName: "payments";
|
|
884
|
+
dataType: "string";
|
|
885
|
+
columnType: "PgText";
|
|
886
|
+
data: string;
|
|
887
|
+
driverParam: string;
|
|
888
|
+
notNull: true;
|
|
889
|
+
hasDefault: false;
|
|
890
|
+
isPrimaryKey: true;
|
|
891
|
+
isAutoincrement: false;
|
|
892
|
+
hasRuntimeDefault: false;
|
|
893
|
+
enumValues: [string, ...string[]];
|
|
894
|
+
baseColumn: never;
|
|
895
|
+
identity: undefined;
|
|
896
|
+
generated: undefined;
|
|
897
|
+
}, {}, {}>;
|
|
898
|
+
provider: import("drizzle-orm/pg-core").PgColumn<{
|
|
899
|
+
name: "provider";
|
|
900
|
+
tableName: "payments";
|
|
901
|
+
dataType: "string";
|
|
902
|
+
columnType: "PgText";
|
|
903
|
+
data: string;
|
|
904
|
+
driverParam: string;
|
|
905
|
+
notNull: true;
|
|
906
|
+
hasDefault: false;
|
|
907
|
+
isPrimaryKey: false;
|
|
908
|
+
isAutoincrement: false;
|
|
909
|
+
hasRuntimeDefault: false;
|
|
910
|
+
enumValues: [string, ...string[]];
|
|
911
|
+
baseColumn: never;
|
|
912
|
+
identity: undefined;
|
|
913
|
+
generated: undefined;
|
|
914
|
+
}, {}, {}>;
|
|
915
|
+
invoiceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
916
|
+
name: "invoice_id";
|
|
917
|
+
tableName: "payments";
|
|
918
|
+
dataType: "string";
|
|
919
|
+
columnType: "PgText";
|
|
920
|
+
data: string;
|
|
921
|
+
driverParam: string;
|
|
922
|
+
notNull: true;
|
|
923
|
+
hasDefault: false;
|
|
924
|
+
isPrimaryKey: false;
|
|
925
|
+
isAutoincrement: false;
|
|
926
|
+
hasRuntimeDefault: false;
|
|
927
|
+
enumValues: [string, ...string[]];
|
|
928
|
+
baseColumn: never;
|
|
929
|
+
identity: undefined;
|
|
930
|
+
generated: undefined;
|
|
931
|
+
}, {}, {}>;
|
|
932
|
+
workspaceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
933
|
+
name: "workspace_id";
|
|
934
|
+
tableName: "payments";
|
|
935
|
+
dataType: "string";
|
|
936
|
+
columnType: "PgText";
|
|
937
|
+
data: string;
|
|
938
|
+
driverParam: string;
|
|
939
|
+
notNull: true;
|
|
940
|
+
hasDefault: false;
|
|
941
|
+
isPrimaryKey: false;
|
|
942
|
+
isAutoincrement: false;
|
|
943
|
+
hasRuntimeDefault: false;
|
|
944
|
+
enumValues: [string, ...string[]];
|
|
945
|
+
baseColumn: never;
|
|
946
|
+
identity: undefined;
|
|
947
|
+
generated: undefined;
|
|
948
|
+
}, {}, {}>;
|
|
949
|
+
userId: import("drizzle-orm/pg-core").PgColumn<{
|
|
950
|
+
name: "user_id";
|
|
951
|
+
tableName: "payments";
|
|
952
|
+
dataType: "string";
|
|
953
|
+
columnType: "PgText";
|
|
954
|
+
data: string;
|
|
955
|
+
driverParam: string;
|
|
956
|
+
notNull: false;
|
|
957
|
+
hasDefault: false;
|
|
958
|
+
isPrimaryKey: false;
|
|
959
|
+
isAutoincrement: false;
|
|
960
|
+
hasRuntimeDefault: false;
|
|
961
|
+
enumValues: [string, ...string[]];
|
|
962
|
+
baseColumn: never;
|
|
963
|
+
identity: undefined;
|
|
964
|
+
generated: undefined;
|
|
965
|
+
}, {}, {}>;
|
|
966
|
+
reference: import("drizzle-orm/pg-core").PgColumn<{
|
|
967
|
+
name: "reference";
|
|
968
|
+
tableName: "payments";
|
|
969
|
+
dataType: "string";
|
|
970
|
+
columnType: "PgText";
|
|
971
|
+
data: string;
|
|
972
|
+
driverParam: string;
|
|
973
|
+
notNull: true;
|
|
974
|
+
hasDefault: false;
|
|
975
|
+
isPrimaryKey: false;
|
|
976
|
+
isAutoincrement: false;
|
|
977
|
+
hasRuntimeDefault: false;
|
|
978
|
+
enumValues: [string, ...string[]];
|
|
979
|
+
baseColumn: never;
|
|
980
|
+
identity: undefined;
|
|
981
|
+
generated: undefined;
|
|
982
|
+
}, {}, {}>;
|
|
983
|
+
amountMinor: import("drizzle-orm/pg-core").PgColumn<{
|
|
984
|
+
name: "amount_minor";
|
|
985
|
+
tableName: "payments";
|
|
986
|
+
dataType: "number";
|
|
987
|
+
columnType: "PgInteger";
|
|
988
|
+
data: number;
|
|
989
|
+
driverParam: string | number;
|
|
990
|
+
notNull: true;
|
|
991
|
+
hasDefault: false;
|
|
992
|
+
isPrimaryKey: false;
|
|
993
|
+
isAutoincrement: false;
|
|
994
|
+
hasRuntimeDefault: false;
|
|
995
|
+
enumValues: undefined;
|
|
996
|
+
baseColumn: never;
|
|
997
|
+
identity: undefined;
|
|
998
|
+
generated: undefined;
|
|
999
|
+
}, {}, {}>;
|
|
1000
|
+
currency: import("drizzle-orm/pg-core").PgColumn<{
|
|
1001
|
+
name: "currency";
|
|
1002
|
+
tableName: "payments";
|
|
1003
|
+
dataType: "string";
|
|
1004
|
+
columnType: "PgText";
|
|
1005
|
+
data: string;
|
|
1006
|
+
driverParam: string;
|
|
1007
|
+
notNull: true;
|
|
1008
|
+
hasDefault: false;
|
|
1009
|
+
isPrimaryKey: false;
|
|
1010
|
+
isAutoincrement: false;
|
|
1011
|
+
hasRuntimeDefault: false;
|
|
1012
|
+
enumValues: [string, ...string[]];
|
|
1013
|
+
baseColumn: never;
|
|
1014
|
+
identity: undefined;
|
|
1015
|
+
generated: undefined;
|
|
1016
|
+
}, {}, {}>;
|
|
1017
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
1018
|
+
name: "status";
|
|
1019
|
+
tableName: "payments";
|
|
1020
|
+
dataType: "string";
|
|
1021
|
+
columnType: "PgText";
|
|
1022
|
+
data: string;
|
|
1023
|
+
driverParam: string;
|
|
1024
|
+
notNull: true;
|
|
1025
|
+
hasDefault: true;
|
|
1026
|
+
isPrimaryKey: false;
|
|
1027
|
+
isAutoincrement: false;
|
|
1028
|
+
hasRuntimeDefault: false;
|
|
1029
|
+
enumValues: [string, ...string[]];
|
|
1030
|
+
baseColumn: never;
|
|
1031
|
+
identity: undefined;
|
|
1032
|
+
generated: undefined;
|
|
1033
|
+
}, {}, {}>;
|
|
1034
|
+
fulfilledAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1035
|
+
name: "fulfilled_at";
|
|
1036
|
+
tableName: "payments";
|
|
1037
|
+
dataType: "date";
|
|
1038
|
+
columnType: "PgTimestamp";
|
|
1039
|
+
data: Date;
|
|
1040
|
+
driverParam: string;
|
|
1041
|
+
notNull: false;
|
|
1042
|
+
hasDefault: false;
|
|
1043
|
+
isPrimaryKey: false;
|
|
1044
|
+
isAutoincrement: false;
|
|
1045
|
+
hasRuntimeDefault: false;
|
|
1046
|
+
enumValues: undefined;
|
|
1047
|
+
baseColumn: never;
|
|
1048
|
+
identity: undefined;
|
|
1049
|
+
generated: undefined;
|
|
1050
|
+
}, {}, {}>;
|
|
1051
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1052
|
+
name: "created_at";
|
|
1053
|
+
tableName: "payments";
|
|
1054
|
+
dataType: "date";
|
|
1055
|
+
columnType: "PgTimestamp";
|
|
1056
|
+
data: Date;
|
|
1057
|
+
driverParam: string;
|
|
1058
|
+
notNull: true;
|
|
1059
|
+
hasDefault: true;
|
|
1060
|
+
isPrimaryKey: false;
|
|
1061
|
+
isAutoincrement: false;
|
|
1062
|
+
hasRuntimeDefault: false;
|
|
1063
|
+
enumValues: undefined;
|
|
1064
|
+
baseColumn: never;
|
|
1065
|
+
identity: undefined;
|
|
1066
|
+
generated: undefined;
|
|
1067
|
+
}, {}, {}>;
|
|
1068
|
+
};
|
|
1069
|
+
dialect: "pg";
|
|
1070
|
+
}>;
|
|
868
1071
|
/** Every Stripe event, for idempotent webhook processing and audit. */
|
|
869
1072
|
export declare const financeEvents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
870
1073
|
name: "finance_events";
|
|
@@ -1219,6 +1422,8 @@ export type CreditBalance = typeof creditBalances.$inferSelect;
|
|
|
1219
1422
|
export type InsertCreditBalance = typeof creditBalances.$inferInsert;
|
|
1220
1423
|
export type CreditPurchase = typeof creditPurchases.$inferSelect;
|
|
1221
1424
|
export type InsertCreditPurchase = typeof creditPurchases.$inferInsert;
|
|
1425
|
+
export type Payment = typeof payments.$inferSelect;
|
|
1426
|
+
export type InsertPayment = typeof payments.$inferInsert;
|
|
1222
1427
|
export type FinanceEvent = typeof financeEvents.$inferSelect;
|
|
1223
1428
|
export type InsertFinanceEvent = typeof financeEvents.$inferInsert;
|
|
1224
1429
|
export type BillingSettings = typeof billingSettings.$inferSelect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../../src/db/schema/billing.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../../src/db/schema/billing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;;;GAIG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAO,QAAQ,CAAC,YAAY,CAAC;AACnD,MAAM,MAAM,aAAa,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAC;AACzD,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAC,YAAY,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,OAAO,aAAa,CAAC,YAAY,CAAC;AACnE,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,YAAY,CAAC;AAClE,MAAM,MAAM,qBAAqB,GAAG,OAAO,eAAe,CAAC,YAAY,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,OAAO,kBAAkB,CAAC,YAAY,CAAC;AACvE,MAAM,MAAM,uBAAuB,GAAG,OAAO,kBAAkB,CAAC,YAAY,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plans, subscriptions, credit ledgers, purchases
|
|
3
|
-
* Amounts in the credit ledgers are micros of their
|
|
2
|
+
* Plans, subscriptions, credit ledgers, purchases, local payments and
|
|
3
|
+
* Stripe events. Amounts in the credit ledgers are micros of their
|
|
4
|
+
* currency; amounts a buyer paid are minor units of theirs.
|
|
4
5
|
*/
|
|
5
6
|
import { pgTable, text, timestamp, integer, bigint, boolean, index, unique, } from "drizzle-orm/pg-core";
|
|
6
|
-
import { organization } from "./auth.js";
|
|
7
|
+
import { organization, users } from "./auth.js";
|
|
7
8
|
/**
|
|
8
9
|
* The registered plan catalogue, copied into rows so a subscription can
|
|
9
10
|
* reference its plan. The catalogue is the source: the rows are written
|
|
@@ -111,6 +112,34 @@ export const creditPurchases = pgTable("credit_purchases", {
|
|
|
111
112
|
status: text("status").notNull().default("pending"), // pending|completed|failed
|
|
112
113
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
113
114
|
}, (table) => [index("credit_purchases_workspace_id_idx").on(table.workspaceId)]);
|
|
115
|
+
/**
|
|
116
|
+
* Invoices issued through a registered payment provider (QR-and-poll
|
|
117
|
+
* methods such as QPay, PIX or UPI), one row per invoice. The row is
|
|
118
|
+
* written when the invoice is opened, so settlement knows who pays and
|
|
119
|
+
* what was priced without trusting the browser; `fulfilled_at` is set
|
|
120
|
+
* in the same transaction that grants what was bought, so a payment is
|
|
121
|
+
* granted once however many polls see it paid.
|
|
122
|
+
*/
|
|
123
|
+
export const payments = pgTable("payments", {
|
|
124
|
+
id: text("id").primaryKey(),
|
|
125
|
+
/** The PAYMENT_MODE the invoice was opened under; settlement asks the same provider. */
|
|
126
|
+
provider: text("provider").notNull(),
|
|
127
|
+
invoiceId: text("invoice_id").notNull().unique(),
|
|
128
|
+
workspaceId: text("workspace_id")
|
|
129
|
+
.notNull()
|
|
130
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
131
|
+
userId: text("user_id").references(() => users.id, {
|
|
132
|
+
onDelete: "set null",
|
|
133
|
+
}),
|
|
134
|
+
/** What was bought, in the product's words: a plan slug, a bundle id. */
|
|
135
|
+
reference: text("reference").notNull(),
|
|
136
|
+
/** The price, in minor units of `currency`. */
|
|
137
|
+
amountMinor: integer("amount_minor").notNull(),
|
|
138
|
+
currency: text("currency").notNull(),
|
|
139
|
+
status: text("status").notNull().default("pending"), // pending|paid|failed
|
|
140
|
+
fulfilledAt: timestamp("fulfilled_at"),
|
|
141
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
142
|
+
}, (table) => [index("payments_workspace_id_idx").on(table.workspaceId)]);
|
|
114
143
|
/** Every Stripe event, for idempotent webhook processing and audit. */
|
|
115
144
|
export const financeEvents = pgTable("finance_events", {
|
|
116
145
|
id: text("id").primaryKey(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/db/schema/billing.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/db/schema/billing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,OAAO,EACP,IAAI,EACJ,SAA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AAC,MAAM,EAAE;IAChD,yCAAyC;IACzC,eAAe,EAAE,MAAM,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SAC5D,OAAO,EAAE;SACT,OAAO,CAAC,CAAC,CAAC;IACb,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACnD,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,mBAAmB;IACvE,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;IACzD,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC5C,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC;CACnC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC;IACT,KAAK,CAAC,gCAAgC,CAAC,CAAC,EAAE,CACxC,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,SAAS,CAChB;CACF,CACF,CAAC"}
|
package/dist/identity/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Privacy-facing reads and mutations over the user identity graph: fact
|
|
3
|
-
* listing and deletion,
|
|
3
|
+
* listing and deletion, the profile snapshot's write, full-identity
|
|
4
|
+
* export, and the memory-audit trail.
|
|
4
5
|
*/
|
|
5
|
-
export { listFacts, deleteFact, exportIdentity, getAuditTrail, } from "./service.js";
|
|
6
|
+
export { listFacts, deleteFact, saveProfileSnapshot, exportIdentity, getAuditTrail, } from "./service.js";
|
|
6
7
|
export { IdentityServiceError, isIdentityServiceError, type IdentityServiceErrorCode, } from "./errors.js";
|
|
7
|
-
export type { IdentityActor, IdentityExport, UserFact, UserMemory, UserProfileSnapshot, UserMemoryAuditRow, } from "./types.js";
|
|
8
|
+
export type { IdentityActor, IdentityExport, SaveProfileSnapshotInput, UserFact, UserMemory, UserProfileSnapshot, UserMemoryAuditRow, } from "./types.js";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
package/dist/identity/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Privacy-facing reads and mutations over the user identity graph: fact
|
|
3
|
-
* listing and deletion,
|
|
3
|
+
* listing and deletion, the profile snapshot's write, full-identity
|
|
4
|
+
* export, and the memory-audit trail.
|
|
4
5
|
*/
|
|
5
|
-
export { listFacts, deleteFact, exportIdentity, getAuditTrail, } from "./service.js";
|
|
6
|
+
export { listFacts, deleteFact, saveProfileSnapshot, exportIdentity, getAuditTrail, } from "./service.js";
|
|
6
7
|
export { IdentityServiceError, isIdentityServiceError, } from "./errors.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GAEvB,MAAM,UAAU,CAAC"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server-only reads and mutations over the user identity graph: fact
|
|
3
|
-
* listing and deletion, a full data export,
|
|
3
|
+
* listing and deletion, the profile snapshot's write, a full data export,
|
|
4
|
+
* and the memory-audit trail.
|
|
4
5
|
*
|
|
5
6
|
* `deleteFact` does not touch the cached profile snapshot; profile synthesis
|
|
6
|
-
* is the product's AI code, so a caller that owns it re-triggers it
|
|
7
|
+
* is the product's AI code, so a caller that owns it re-triggers it and
|
|
8
|
+
* stores the result with `saveProfileSnapshot`.
|
|
7
9
|
*
|
|
8
10
|
* Callers pass a resolved actor (workspaceId, userId); core cannot depend on
|
|
9
11
|
* `@intelligo-dev/auth`. Every query filters by both ids. Every mutation
|
|
10
12
|
* writes a `user_memory_audit` row. Failures throw `IdentityServiceError`.
|
|
11
13
|
*/
|
|
12
|
-
import type { UserFact, UserMemoryAuditRow } from "../db/schema/index.js";
|
|
13
|
-
import type { IdentityActor, IdentityExport } from "./types.js";
|
|
14
|
+
import type { UserFact, UserMemoryAuditRow, UserProfileSnapshot } from "../db/schema/index.js";
|
|
15
|
+
import type { IdentityActor, IdentityExport, SaveProfileSnapshotInput } from "./types.js";
|
|
14
16
|
/** List the actor's facts, most important and most confident first. */
|
|
15
17
|
export declare function listFacts(actor: IdentityActor): Promise<UserFact[]>;
|
|
16
18
|
/**
|
|
@@ -33,4 +35,18 @@ export declare function deleteFact(actor: IdentityActor, factId: string): Promis
|
|
|
33
35
|
* audit row (action "export").
|
|
34
36
|
*/
|
|
35
37
|
export declare function exportIdentity(actor: IdentityActor): Promise<IdentityExport>;
|
|
38
|
+
/**
|
|
39
|
+
* Store the actor's synthesized profile — one row per user per workspace,
|
|
40
|
+
* inserted on the first synthesis and replaced on every later one. The
|
|
41
|
+
* version is bumped in the same statement (`ON CONFLICT … version + 1`),
|
|
42
|
+
* so two syntheses racing each other get two versions rather than one
|
|
43
|
+
* overwriting the other's number; it starts at 1.
|
|
44
|
+
*
|
|
45
|
+
* A field left `undefined` keeps what the row holds (null on insert); an
|
|
46
|
+
* explicit `null` clears it. `synthesizedAt` defaults to now. Records an
|
|
47
|
+
* audit row (`snapshot`, `create` or `update`) in the same transaction,
|
|
48
|
+
* attributed to `input.actorKind` — `system_job` unless the caller says
|
|
49
|
+
* otherwise. Throws `invalid_input` for an empty summary.
|
|
50
|
+
*/
|
|
51
|
+
export declare function saveProfileSnapshot(actor: IdentityActor, input: SaveProfileSnapshotInput): Promise<UserProfileSnapshot>;
|
|
36
52
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/identity/service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/identity/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,wBAAwB,EACzB,MAAM,SAAS,CAAC;AA4BjB,uEAAuE;AACvE,wBAAsB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAWzE;AAID;;;GAGG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,aAAa,EACpB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9C,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAqB/B;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,cAAc,CAAC,CA+DzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,mBAAmB,CAAC,CAkE9B"}
|
package/dist/identity/service.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server-only reads and mutations over the user identity graph: fact
|
|
3
|
-
* listing and deletion, a full data export,
|
|
3
|
+
* listing and deletion, the profile snapshot's write, a full data export,
|
|
4
|
+
* and the memory-audit trail.
|
|
4
5
|
*
|
|
5
6
|
* `deleteFact` does not touch the cached profile snapshot; profile synthesis
|
|
6
|
-
* is the product's AI code, so a caller that owns it re-triggers it
|
|
7
|
+
* is the product's AI code, so a caller that owns it re-triggers it and
|
|
8
|
+
* stores the result with `saveProfileSnapshot`.
|
|
7
9
|
*
|
|
8
10
|
* Callers pass a resolved actor (workspaceId, userId); core cannot depend on
|
|
9
11
|
* `@intelligo-dev/auth`. Every query filters by both ids. Every mutation
|
|
10
12
|
* writes a `user_memory_audit` row. Failures throw `IdentityServiceError`.
|
|
11
13
|
*/
|
|
12
|
-
import { and, desc, eq } from "drizzle-orm";
|
|
14
|
+
import { and, desc, eq, sql } from "drizzle-orm";
|
|
13
15
|
import { db } from "../db/index.js";
|
|
14
16
|
import { userFacts, userMemories, userProfileSnapshots, userMemoryAudit, } from "../db/schema/index.js";
|
|
15
17
|
import { recordMemoryAudit } from "./audit.js";
|
|
@@ -129,4 +131,77 @@ export async function exportIdentity(actor) {
|
|
|
129
131
|
audit,
|
|
130
132
|
};
|
|
131
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Store the actor's synthesized profile — one row per user per workspace,
|
|
136
|
+
* inserted on the first synthesis and replaced on every later one. The
|
|
137
|
+
* version is bumped in the same statement (`ON CONFLICT … version + 1`),
|
|
138
|
+
* so two syntheses racing each other get two versions rather than one
|
|
139
|
+
* overwriting the other's number; it starts at 1.
|
|
140
|
+
*
|
|
141
|
+
* A field left `undefined` keeps what the row holds (null on insert); an
|
|
142
|
+
* explicit `null` clears it. `synthesizedAt` defaults to now. Records an
|
|
143
|
+
* audit row (`snapshot`, `create` or `update`) in the same transaction,
|
|
144
|
+
* attributed to `input.actorKind` — `system_job` unless the caller says
|
|
145
|
+
* otherwise. Throws `invalid_input` for an empty summary.
|
|
146
|
+
*/
|
|
147
|
+
export async function saveProfileSnapshot(actor, input) {
|
|
148
|
+
if (!input.summary || input.summary.trim().length === 0) {
|
|
149
|
+
throw new IdentityServiceError("invalid_input", "summary is required");
|
|
150
|
+
}
|
|
151
|
+
if (input.factsDigest === undefined || input.factsDigest === null) {
|
|
152
|
+
throw new IdentityServiceError("invalid_input", "factsDigest is required");
|
|
153
|
+
}
|
|
154
|
+
const replaced = {
|
|
155
|
+
summary: input.summary,
|
|
156
|
+
factsDigest: input.factsDigest,
|
|
157
|
+
synthesizedAt: input.synthesizedAt ?? new Date(),
|
|
158
|
+
...definedOnly({
|
|
159
|
+
summaryEn: input.summaryEn,
|
|
160
|
+
summaryMn: input.summaryMn,
|
|
161
|
+
activeGoals: input.activeGoals,
|
|
162
|
+
personalitySignals: input.personalitySignals,
|
|
163
|
+
relationshipNotes: input.relationshipNotes,
|
|
164
|
+
synthesizedByModel: input.synthesizedByModel,
|
|
165
|
+
nextSynthesisAt: input.nextSynthesisAt,
|
|
166
|
+
triggerReason: input.triggerReason,
|
|
167
|
+
}),
|
|
168
|
+
};
|
|
169
|
+
return db.transaction(async (tx) => {
|
|
170
|
+
const [row] = await tx
|
|
171
|
+
.insert(userProfileSnapshots)
|
|
172
|
+
.values({
|
|
173
|
+
userId: actor.userId,
|
|
174
|
+
workspaceId: actor.workspaceId,
|
|
175
|
+
version: 1,
|
|
176
|
+
...replaced,
|
|
177
|
+
})
|
|
178
|
+
.onConflictDoUpdate({
|
|
179
|
+
target: [userProfileSnapshots.userId, userProfileSnapshots.workspaceId],
|
|
180
|
+
set: {
|
|
181
|
+
...replaced,
|
|
182
|
+
version: sql `${userProfileSnapshots.version} + 1`,
|
|
183
|
+
},
|
|
184
|
+
})
|
|
185
|
+
.returning();
|
|
186
|
+
if (!row) {
|
|
187
|
+
throw new IdentityServiceError("database_error", "Failed to save profile snapshot");
|
|
188
|
+
}
|
|
189
|
+
await recordMemoryAudit({
|
|
190
|
+
userId: actor.userId,
|
|
191
|
+
workspaceId: actor.workspaceId,
|
|
192
|
+
targetKind: "snapshot",
|
|
193
|
+
targetId: actor.userId,
|
|
194
|
+
action: row.version === 1 ? "create" : "update",
|
|
195
|
+
actorKind: input.actorKind ?? "system_job",
|
|
196
|
+
actorId: input.actorId,
|
|
197
|
+
afterValue: { version: row.version, triggerReason: row.triggerReason },
|
|
198
|
+
reason: input.reason,
|
|
199
|
+
}, tx);
|
|
200
|
+
return row;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/** The entries whose value is not `undefined` — `null` is kept, to clear. */
|
|
204
|
+
function definedOnly(fields) {
|
|
205
|
+
return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
|
|
206
|
+
}
|
|
132
207
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/identity/service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/identity/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EACL,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,MAAM;YACpB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,UAAU,EAAE,UAAU;YACtB,QAAQ,EAAE,KAAK,CAAC,MAAM;YACtB,MAAM,EAAE,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;YAC/C,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,YAAY;YAC1C,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,UAAU,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE;YACtE,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,EACD,EAAE,CACH,CAAC;QAEF,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC;AAED,6EAA6E;AAC7E,SAAS,WAAW,CAAoC,MAAS;IAC/D,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CACpD,CAAC;AAClB,CAAC"}
|
package/dist/identity/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UserFact, UserMemory, UserProfileSnapshot, UserMemoryAuditRow } from "../db/schema/index.js";
|
|
1
|
+
import type { AuditActorKind, SynthesisTriggerReason, UserFact, UserMemory, UserProfileSnapshot, UserMemoryAuditRow } from "../db/schema/index.js";
|
|
2
2
|
export type { UserFact, UserMemory, UserProfileSnapshot, UserMemoryAuditRow };
|
|
3
3
|
/** Resolved actor identity — every query is scoped to this pair. */
|
|
4
4
|
export type IdentityActor = {
|
|
@@ -21,4 +21,31 @@ export type IdentityExport = {
|
|
|
21
21
|
snapshot: UserProfileSnapshot | null;
|
|
22
22
|
audit: UserMemoryAuditRow[];
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* A synthesized profile, as `saveProfileSnapshot` stores it. The actor
|
|
26
|
+
* supplies the tenancy; the version is the store's.
|
|
27
|
+
*/
|
|
28
|
+
export type SaveProfileSnapshotInput = {
|
|
29
|
+
/** The summary a prompt hydrates from, in the product's primary language. */
|
|
30
|
+
summary: string;
|
|
31
|
+
summaryEn?: string | null;
|
|
32
|
+
summaryMn?: string | null;
|
|
33
|
+
/** The structured digest the summary was written from. */
|
|
34
|
+
factsDigest: unknown;
|
|
35
|
+
activeGoals?: unknown;
|
|
36
|
+
personalitySignals?: unknown;
|
|
37
|
+
relationshipNotes?: unknown;
|
|
38
|
+
/** The model that wrote it, or a label for a deterministic synthesis. */
|
|
39
|
+
synthesizedByModel?: string | null;
|
|
40
|
+
/** Default: now. */
|
|
41
|
+
synthesizedAt?: Date;
|
|
42
|
+
/** When a scheduled re-synthesis may next pick this user up. */
|
|
43
|
+
nextSynthesisAt?: Date | null;
|
|
44
|
+
triggerReason?: SynthesisTriggerReason | null;
|
|
45
|
+
/** Who the audit row names. Default `"system_job"`. */
|
|
46
|
+
actorKind?: AuditActorKind;
|
|
47
|
+
actorId?: string;
|
|
48
|
+
/** Recorded on the audit row. */
|
|
49
|
+
reason?: string;
|
|
50
|
+
};
|
|
24
51
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/identity/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;AAE9E,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc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,0DAA0D;IAC1D,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,oBAAoB;IACpB,aAAa,CAAC,EAAE,IAAI,CAAC;IACrB,gEAAgE;IAChE,eAAe,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC9C,uDAAuD;IACvD,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* their notifications from every workspace.
|
|
4
4
|
*/
|
|
5
5
|
import type { CreateNotificationParams } from "./types.js";
|
|
6
|
-
export type { NotificationType, CreateNotificationParams } from "./types.js";
|
|
6
|
+
export type { BuiltInNotificationType, NotificationType, CreateNotificationParams, } from "./types.js";
|
|
7
7
|
export { triggerQuotaNotification, triggerTrialNotification, triggerPaymentFailedNotification, triggerTeamMemberJoinedNotification, } from "./triggers.js";
|
|
8
8
|
/** Creates a notification; `metadata` is stored as a JSON string. */
|
|
9
9
|
export declare function createNotification(params: CreateNotificationParams): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,YAAY,EACV,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gCAAgC,EAChC,mCAAmC,GACpC,MAAM,YAAY,CAAC;AAEpB,qEAAqE;AACrE,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB;;;;;;;;;;eAcxE;AAED,qDAAqD;AACrD,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAW;;;;;;;;;;;cA6DD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;MAjDhD;AAED,qDAAqD;AACrD,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW;;;;;;;;;;;cA8CtD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;MArChD;AAED,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS1E;AAED,mEAAmE;AACnE,wBAAsB,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAUtE;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,iBAOjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,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ChD,MAAM,EAAE;SACL,MAAM,CAAC,aAAa,CAAC;SACrB,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SACrB,KAAK,CACJ,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACvE,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CACpB,YAAe;IAEf,OAAO;QACL,GAAG,YAAY;QACf,QAAQ,EAAE,YAAY,CAAC,QAAQ;YAC7B,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAA6B;YAChE,CAAC,CAAC,IAAI;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/** The notification types the framework itself creates. */
|
|
2
|
+
export type BuiltInNotificationType = "quota_warning_80" | "quota_warning_100" | "trial_warning_20" | "trial_depleted" | "payment_failed" | "team_member_joined" | "subscription_confirmed" | "workspace_invitation";
|
|
3
|
+
/**
|
|
4
|
+
* A notification's `type`: one of the built-in types, or any string a
|
|
5
|
+
* product defines for its own notifications. `(string & {})` keeps the
|
|
6
|
+
* built-in names offered by autocompletion.
|
|
7
|
+
*/
|
|
8
|
+
export type NotificationType = BuiltInNotificationType | (string & {});
|
|
2
9
|
export interface CreateNotificationParams {
|
|
3
10
|
userId: string;
|
|
4
11
|
workspaceId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,MAAM,uBAAuB,GAC/B,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,oBAAoB,GACpB,wBAAwB,GACxB,sBAAsB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,uBAAuB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
|