financial-graph-shared 1.0.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.
- package/README.md +75 -0
- package/dist/db/index.d.ts +11 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +11 -0
- package/dist/db/queries/cik-lookup.d.ts +49 -0
- package/dist/db/queries/cik-lookup.d.ts.map +1 -0
- package/dist/db/queries/cik-lookup.js +78 -0
- package/dist/db/queries/company-lookup.d.ts +43 -0
- package/dist/db/queries/company-lookup.d.ts.map +1 -0
- package/dist/db/queries/company-lookup.js +65 -0
- package/dist/db/queries/index.d.ts +8 -0
- package/dist/db/queries/index.d.ts.map +1 -0
- package/dist/db/queries/index.js +7 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/instant.schema.d.ts +170 -0
- package/dist/instant.schema.d.ts.map +1 -0
- package/dist/instant.schema.js +222 -0
- package/dist/types/ids.d.ts +135 -0
- package/dist/types/ids.d.ts.map +1 -0
- package/dist/types/ids.js +188 -0
- package/dist/types/instant.schema.future.d.ts +39 -0
- package/dist/types/instant.schema.future.d.ts.map +1 -0
- package/dist/types/instant.schema.future.js +52 -0
- package/dist/types/types.d.ts +321 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +180 -0
- package/dist/types/validation.d.ts +7 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/dist/types/validation.js +14 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/logger-interface.d.ts +57 -0
- package/dist/utils/logger-interface.d.ts.map +1 -0
- package/dist/utils/logger-interface.js +38 -0
- package/package.json +54 -0
- package/types/ids.ts +249 -0
- package/types/instant.schema.future.js +55 -0
- package/types/instant.schema.future.ts +59 -0
- package/types/types.ts +292 -0
- package/types/validation.ts +32 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Database Types & Validation
|
|
3
|
+
*
|
|
4
|
+
* InstantDB handles: type checking, required/optional, unique constraints
|
|
5
|
+
* We handle: business logic validation that InstantDB can't express
|
|
6
|
+
*
|
|
7
|
+
* Types vs Interfaces:
|
|
8
|
+
* - `type` aliases are direct re-exports from InstantDB (InstaQLEntity)
|
|
9
|
+
* - `interface` adds proper typing for enum/JSON fields that InstantDB types as number/any
|
|
10
|
+
* - Code should use the interfaces (Company, ParentOfEdge) not the raw types
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import type { InstaQLEntity } from "@instantdb/core";
|
|
14
|
+
import type schema from "../instant.schema";
|
|
15
|
+
export declare const CompanyType: {
|
|
16
|
+
readonly PUBLIC: 1;
|
|
17
|
+
readonly PRIVATE: 2;
|
|
18
|
+
readonly ISSUER: 3;
|
|
19
|
+
readonly UNKNOWN: 4;
|
|
20
|
+
readonly TRUST: 5;
|
|
21
|
+
};
|
|
22
|
+
export type CompanyTypeValue = (typeof CompanyType)[keyof typeof CompanyType];
|
|
23
|
+
export declare const ParentOfSource: {
|
|
24
|
+
readonly MA_EVENT: 1;
|
|
25
|
+
readonly SPINOFF: 2;
|
|
26
|
+
readonly IPO: 3;
|
|
27
|
+
readonly MANUAL: 4;
|
|
28
|
+
readonly SEC_FILING: 5;
|
|
29
|
+
};
|
|
30
|
+
export type ParentOfSourceValue = (typeof ParentOfSource)[keyof typeof ParentOfSource];
|
|
31
|
+
type CompanyRaw = InstaQLEntity<typeof schema, "company">;
|
|
32
|
+
type ParentOfEdgeRaw = InstaQLEntity<typeof schema, "parent_of">;
|
|
33
|
+
export type Filing = InstaQLEntity<typeof schema, "filing">;
|
|
34
|
+
export type FilingAttachments = Record<string, string>;
|
|
35
|
+
export type SubsidiaryEnrichment = InstaQLEntity<typeof schema, "subsidiary_enrichment">;
|
|
36
|
+
export type Audit = InstaQLEntity<typeof schema, "audit">;
|
|
37
|
+
/** JSON structure for company.identity field */
|
|
38
|
+
export interface CompanyIdentity {
|
|
39
|
+
primaryCIK?: string;
|
|
40
|
+
ciks?: string;
|
|
41
|
+
tickers?: string;
|
|
42
|
+
exchanges?: string;
|
|
43
|
+
sp500?: boolean;
|
|
44
|
+
lei?: string;
|
|
45
|
+
duns?: string;
|
|
46
|
+
entityType?: string;
|
|
47
|
+
sic?: string;
|
|
48
|
+
sicDescription?: string;
|
|
49
|
+
ein?: string;
|
|
50
|
+
category?: string;
|
|
51
|
+
ownerOrg?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Company with properly typed `type` (enum) and `identity` (JSON) */
|
|
54
|
+
export interface Company extends Omit<CompanyRaw, "type" | "identity"> {
|
|
55
|
+
type: CompanyTypeValue;
|
|
56
|
+
identity?: CompanyIdentity;
|
|
57
|
+
}
|
|
58
|
+
/** ParentOfEdge with properly typed `source` (enum) */
|
|
59
|
+
export interface ParentOfEdge extends Omit<ParentOfEdgeRaw, "source"> {
|
|
60
|
+
source: ParentOfSourceValue;
|
|
61
|
+
}
|
|
62
|
+
/** JSON structure for audit.fields_changed array items */
|
|
63
|
+
export interface FieldChange {
|
|
64
|
+
field: string;
|
|
65
|
+
old_value: unknown;
|
|
66
|
+
new_value: unknown;
|
|
67
|
+
}
|
|
68
|
+
/** Audit with properly typed `fields_changed` (JSON array) */
|
|
69
|
+
export interface AuditWithChanges extends Omit<Audit, "fields_changed"> {
|
|
70
|
+
fields_changed: FieldChange[];
|
|
71
|
+
}
|
|
72
|
+
export declare const NonEmptyString: z.ZodString;
|
|
73
|
+
export declare const IntNumber: z.ZodNumber;
|
|
74
|
+
/** CIK: 1-10 digit numeric string, normalized to 10 digits with leading zeros */
|
|
75
|
+
export declare const CIKString: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
76
|
+
/**
|
|
77
|
+
* Accession Number: SEC filing identifier
|
|
78
|
+
* Format: XXXXXXXXXX-XX-XXXXXX (with dashes) or XXXXXXXXXXXXXXXXXX (without)
|
|
79
|
+
* Normalized by removing dashes
|
|
80
|
+
*/
|
|
81
|
+
export declare const AccessionNumberString: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
82
|
+
/** Jurisdiction: rejects numbers/percentages (common parsing errors) */
|
|
83
|
+
export declare const JurisdictionString: z.ZodString;
|
|
84
|
+
/** PUBLIC company: requires name, identity required */
|
|
85
|
+
export declare const PublicCompanySchema: z.ZodObject<{
|
|
86
|
+
type: z.ZodLiteral<1>;
|
|
87
|
+
name: z.ZodString;
|
|
88
|
+
identity: z.ZodObject<{
|
|
89
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
90
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
91
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
92
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
93
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
95
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
96
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
97
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
98
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
99
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
100
|
+
category: z.ZodOptional<z.ZodString>;
|
|
101
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
jurisdiction_raw: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
/** PRIVATE company: requires name + jurisdiction, identity optional */
|
|
106
|
+
export declare const PrivateCompanySchema: z.ZodObject<{
|
|
107
|
+
type: z.ZodLiteral<2>;
|
|
108
|
+
name: z.ZodString;
|
|
109
|
+
jurisdiction_raw: z.ZodString;
|
|
110
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
111
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
112
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
113
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
114
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
115
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
117
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
118
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
119
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
120
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
121
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
122
|
+
category: z.ZodOptional<z.ZodString>;
|
|
123
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
124
|
+
}, z.core.$strip>>;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
/** ISSUER company: requires name, identity required */
|
|
127
|
+
export declare const IssuerCompanySchema: z.ZodObject<{
|
|
128
|
+
type: z.ZodLiteral<3>;
|
|
129
|
+
name: z.ZodString;
|
|
130
|
+
identity: z.ZodObject<{
|
|
131
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
132
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
133
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
134
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
135
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
136
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
137
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
138
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
139
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
140
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
141
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
142
|
+
category: z.ZodOptional<z.ZodString>;
|
|
143
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
jurisdiction_raw: z.ZodOptional<z.ZodString>;
|
|
146
|
+
}, z.core.$strip>;
|
|
147
|
+
/** UNKNOWN company: requires name, jurisdiction optional, identity optional */
|
|
148
|
+
export declare const UnknownCompanySchema: z.ZodObject<{
|
|
149
|
+
type: z.ZodLiteral<4>;
|
|
150
|
+
name: z.ZodString;
|
|
151
|
+
jurisdiction_raw: z.ZodOptional<z.ZodString>;
|
|
152
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
153
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
154
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
155
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
156
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
157
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
159
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
160
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
161
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
162
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
163
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
164
|
+
category: z.ZodOptional<z.ZodString>;
|
|
165
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
166
|
+
}, z.core.$strip>>;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
/** TRUST company: requires name, identity optional */
|
|
169
|
+
export declare const TrustCompanySchema: z.ZodObject<{
|
|
170
|
+
type: z.ZodLiteral<5>;
|
|
171
|
+
name: z.ZodString;
|
|
172
|
+
jurisdiction_raw: z.ZodOptional<z.ZodString>;
|
|
173
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
174
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
175
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
176
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
177
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
178
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
179
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
180
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
181
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
182
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
183
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
184
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
185
|
+
category: z.ZodOptional<z.ZodString>;
|
|
186
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>>;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
/** Company validation by type */
|
|
190
|
+
export declare const CompanySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
191
|
+
type: z.ZodLiteral<1>;
|
|
192
|
+
name: z.ZodString;
|
|
193
|
+
identity: z.ZodObject<{
|
|
194
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
195
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
196
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
197
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
198
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
199
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
200
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
201
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
202
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
203
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
204
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
205
|
+
category: z.ZodOptional<z.ZodString>;
|
|
206
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
207
|
+
}, z.core.$strip>;
|
|
208
|
+
jurisdiction_raw: z.ZodOptional<z.ZodString>;
|
|
209
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
210
|
+
type: z.ZodLiteral<2>;
|
|
211
|
+
name: z.ZodString;
|
|
212
|
+
jurisdiction_raw: z.ZodString;
|
|
213
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
214
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
215
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
216
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
217
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
218
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
219
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
220
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
221
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
222
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
223
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
224
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
225
|
+
category: z.ZodOptional<z.ZodString>;
|
|
226
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
227
|
+
}, z.core.$strip>>;
|
|
228
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
229
|
+
type: z.ZodLiteral<3>;
|
|
230
|
+
name: z.ZodString;
|
|
231
|
+
identity: z.ZodObject<{
|
|
232
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
233
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
234
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
235
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
236
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
237
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
238
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
239
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
240
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
241
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
242
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
243
|
+
category: z.ZodOptional<z.ZodString>;
|
|
244
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
jurisdiction_raw: z.ZodOptional<z.ZodString>;
|
|
247
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
248
|
+
type: z.ZodLiteral<4>;
|
|
249
|
+
name: z.ZodString;
|
|
250
|
+
jurisdiction_raw: z.ZodOptional<z.ZodString>;
|
|
251
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
252
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
253
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
254
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
255
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
256
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
257
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
258
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
259
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
260
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
261
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
262
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
263
|
+
category: z.ZodOptional<z.ZodString>;
|
|
264
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
265
|
+
}, z.core.$strip>>;
|
|
266
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
267
|
+
type: z.ZodLiteral<5>;
|
|
268
|
+
name: z.ZodString;
|
|
269
|
+
jurisdiction_raw: z.ZodOptional<z.ZodString>;
|
|
270
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
271
|
+
primaryCIK: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
272
|
+
ciks: z.ZodOptional<z.ZodString>;
|
|
273
|
+
tickers: z.ZodOptional<z.ZodString>;
|
|
274
|
+
exchanges: z.ZodOptional<z.ZodString>;
|
|
275
|
+
sp500: z.ZodOptional<z.ZodBoolean>;
|
|
276
|
+
lei: z.ZodOptional<z.ZodString>;
|
|
277
|
+
duns: z.ZodOptional<z.ZodString>;
|
|
278
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
279
|
+
sic: z.ZodOptional<z.ZodString>;
|
|
280
|
+
sicDescription: z.ZodOptional<z.ZodString>;
|
|
281
|
+
ein: z.ZodOptional<z.ZodString>;
|
|
282
|
+
category: z.ZodOptional<z.ZodString>;
|
|
283
|
+
ownerOrg: z.ZodOptional<z.ZodString>;
|
|
284
|
+
}, z.core.$strip>>;
|
|
285
|
+
}, z.core.$strip>], "type">;
|
|
286
|
+
export declare const ParentOfParamsSchema: z.ZodObject<{
|
|
287
|
+
parentId: z.ZodString;
|
|
288
|
+
subsidiaryId: z.ZodString;
|
|
289
|
+
establishedDate: z.ZodOptional<z.ZodString>;
|
|
290
|
+
}, z.core.$strip>;
|
|
291
|
+
export declare const SubsidiaryEnrichmentParamsSchema: z.ZodObject<{
|
|
292
|
+
companyId: z.ZodString;
|
|
293
|
+
filingId: z.ZodString;
|
|
294
|
+
}, z.core.$strip>;
|
|
295
|
+
export declare const BusinessSegmentParamsSchema: z.ZodObject<{
|
|
296
|
+
companyId: z.ZodString;
|
|
297
|
+
segmentName: z.ZodString;
|
|
298
|
+
fiscalYear: z.ZodNumber;
|
|
299
|
+
fiscalQuarter: z.ZodNullable<z.ZodNumber>;
|
|
300
|
+
}, z.core.$strip>;
|
|
301
|
+
export declare const BrandParamsSchema: z.ZodObject<{
|
|
302
|
+
companyId: z.ZodString;
|
|
303
|
+
name: z.ZodString;
|
|
304
|
+
}, z.core.$strip>;
|
|
305
|
+
export declare const OwnsParamsSchema: z.ZodObject<{
|
|
306
|
+
companyId: z.ZodString;
|
|
307
|
+
brandId: z.ZodString;
|
|
308
|
+
}, z.core.$strip>;
|
|
309
|
+
export declare function isPublicCompany(company: Company): boolean;
|
|
310
|
+
export declare function isPrivateCompany(company: Company): boolean;
|
|
311
|
+
export declare function isFromSecFiling(edge: ParentOfEdge): boolean;
|
|
312
|
+
export declare function validate<T>(schema: z.ZodSchema<T>, data: unknown, schemaName?: string): T;
|
|
313
|
+
export declare function safeValidate<T>(schema: z.ZodSchema<T>, data: unknown): {
|
|
314
|
+
success: true;
|
|
315
|
+
data: T;
|
|
316
|
+
} | {
|
|
317
|
+
success: false;
|
|
318
|
+
error: z.ZodError;
|
|
319
|
+
};
|
|
320
|
+
export {};
|
|
321
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAM5C,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE9E,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAMvD,KAAK,UAAU,GAAG,aAAa,CAAC,OAAO,MAAM,EAAE,SAAS,CAAC,CAAC;AAC1D,KAAK,eAAe,GAAG,aAAa,CAAC,OAAO,MAAM,EAAE,WAAW,CAAC,CAAC;AAGjE,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,MAAM,EAAE,QAA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AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAE3D;AAMD,wBAAgB,QAAQ,CAAC,CAAC,EACxB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,OAAO,EACb,UAAU,CAAC,EAAE,MAAM,GAClB,CAAC,CAcH;AAED,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,OAAO,GACZ;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAA;CAAE,CAMpE"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Database Types & Validation
|
|
3
|
+
*
|
|
4
|
+
* InstantDB handles: type checking, required/optional, unique constraints
|
|
5
|
+
* We handle: business logic validation that InstantDB can't express
|
|
6
|
+
*
|
|
7
|
+
* Types vs Interfaces:
|
|
8
|
+
* - `type` aliases are direct re-exports from InstantDB (InstaQLEntity)
|
|
9
|
+
* - `interface` adds proper typing for enum/JSON fields that InstantDB types as number/any
|
|
10
|
+
* - Code should use the interfaces (Company, ParentOfEdge) not the raw types
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// ENUMS
|
|
15
|
+
// ============================================================================
|
|
16
|
+
export const CompanyType = {
|
|
17
|
+
PUBLIC: 1,
|
|
18
|
+
PRIVATE: 2,
|
|
19
|
+
ISSUER: 3,
|
|
20
|
+
UNKNOWN: 4,
|
|
21
|
+
TRUST: 5,
|
|
22
|
+
};
|
|
23
|
+
export const ParentOfSource = {
|
|
24
|
+
MA_EVENT: 1,
|
|
25
|
+
SPINOFF: 2,
|
|
26
|
+
IPO: 3,
|
|
27
|
+
MANUAL: 4,
|
|
28
|
+
SEC_FILING: 5,
|
|
29
|
+
};
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// FIELD VALIDATORS (business logic InstantDB can't express)
|
|
32
|
+
// ============================================================================
|
|
33
|
+
export const NonEmptyString = z.string().min(1);
|
|
34
|
+
export const IntNumber = z.number().int();
|
|
35
|
+
/** CIK: 1-10 digit numeric string, normalized to 10 digits with leading zeros */
|
|
36
|
+
export const CIKString = z
|
|
37
|
+
.string()
|
|
38
|
+
.regex(/^\d{1,10}$/, "CIK must be 1-10 digits")
|
|
39
|
+
.transform((val) => val.trim().padStart(10, "0"));
|
|
40
|
+
/**
|
|
41
|
+
* Accession Number: SEC filing identifier
|
|
42
|
+
* Format: XXXXXXXXXX-XX-XXXXXX (with dashes) or XXXXXXXXXXXXXXXXXX (without)
|
|
43
|
+
* Normalized by removing dashes
|
|
44
|
+
*/
|
|
45
|
+
export const AccessionNumberString = z
|
|
46
|
+
.string()
|
|
47
|
+
.min(1, "Accession number is required")
|
|
48
|
+
.transform((val) => val.replace(/-/g, ""));
|
|
49
|
+
/** Jurisdiction: rejects numbers/percentages (common parsing errors) */
|
|
50
|
+
export const JurisdictionString = z.string().refine((val) => {
|
|
51
|
+
const trimmed = val.trim();
|
|
52
|
+
if (/^\d+(\.\d+)?$/.test(trimmed))
|
|
53
|
+
return false;
|
|
54
|
+
if (/^\d+(\.\d+)?%$/.test(trimmed))
|
|
55
|
+
return false;
|
|
56
|
+
return true;
|
|
57
|
+
}, { message: "Jurisdiction cannot be a number or percentage" });
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// COMPANY VALIDATION (type-specific rules)
|
|
60
|
+
// ============================================================================
|
|
61
|
+
const CompanyIdentitySchema = z.object({
|
|
62
|
+
primaryCIK: CIKString.optional(),
|
|
63
|
+
ciks: z.string().optional(),
|
|
64
|
+
tickers: z.string().optional(),
|
|
65
|
+
exchanges: z.string().optional(),
|
|
66
|
+
sp500: z.boolean().optional(),
|
|
67
|
+
lei: z.string().length(20).optional(),
|
|
68
|
+
duns: z.string().length(9).optional(),
|
|
69
|
+
entityType: z.string().optional(),
|
|
70
|
+
sic: z.string().optional(),
|
|
71
|
+
sicDescription: z.string().optional(),
|
|
72
|
+
ein: z.string().optional(),
|
|
73
|
+
category: z.string().optional(),
|
|
74
|
+
ownerOrg: z.string().optional(),
|
|
75
|
+
});
|
|
76
|
+
/** PUBLIC company: requires name, identity required */
|
|
77
|
+
export const PublicCompanySchema = z.object({
|
|
78
|
+
type: z.literal(CompanyType.PUBLIC),
|
|
79
|
+
name: NonEmptyString,
|
|
80
|
+
identity: CompanyIdentitySchema,
|
|
81
|
+
jurisdiction_raw: z.string().optional(),
|
|
82
|
+
});
|
|
83
|
+
/** PRIVATE company: requires name + jurisdiction, identity optional */
|
|
84
|
+
export const PrivateCompanySchema = z.object({
|
|
85
|
+
type: z.literal(CompanyType.PRIVATE),
|
|
86
|
+
name: NonEmptyString,
|
|
87
|
+
jurisdiction_raw: JurisdictionString,
|
|
88
|
+
identity: CompanyIdentitySchema.optional(),
|
|
89
|
+
});
|
|
90
|
+
/** ISSUER company: requires name, identity required */
|
|
91
|
+
export const IssuerCompanySchema = z.object({
|
|
92
|
+
type: z.literal(CompanyType.ISSUER),
|
|
93
|
+
name: NonEmptyString,
|
|
94
|
+
identity: CompanyIdentitySchema,
|
|
95
|
+
jurisdiction_raw: z.string().optional(),
|
|
96
|
+
});
|
|
97
|
+
/** UNKNOWN company: requires name, jurisdiction optional, identity optional */
|
|
98
|
+
export const UnknownCompanySchema = z.object({
|
|
99
|
+
type: z.literal(CompanyType.UNKNOWN),
|
|
100
|
+
name: NonEmptyString,
|
|
101
|
+
jurisdiction_raw: JurisdictionString.optional(),
|
|
102
|
+
identity: CompanyIdentitySchema.optional(),
|
|
103
|
+
});
|
|
104
|
+
/** TRUST company: requires name, identity optional */
|
|
105
|
+
export const TrustCompanySchema = z.object({
|
|
106
|
+
type: z.literal(CompanyType.TRUST),
|
|
107
|
+
name: NonEmptyString,
|
|
108
|
+
jurisdiction_raw: z.string().optional(),
|
|
109
|
+
identity: CompanyIdentitySchema.optional(),
|
|
110
|
+
});
|
|
111
|
+
/** Company validation by type */
|
|
112
|
+
export const CompanySchema = z.discriminatedUnion("type", [
|
|
113
|
+
PublicCompanySchema,
|
|
114
|
+
PrivateCompanySchema,
|
|
115
|
+
IssuerCompanySchema,
|
|
116
|
+
UnknownCompanySchema,
|
|
117
|
+
TrustCompanySchema,
|
|
118
|
+
]);
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// ID GENERATION PARAMS (for composite key generation)
|
|
121
|
+
// ============================================================================
|
|
122
|
+
export const ParentOfParamsSchema = z.object({
|
|
123
|
+
parentId: NonEmptyString,
|
|
124
|
+
subsidiaryId: NonEmptyString,
|
|
125
|
+
establishedDate: NonEmptyString.optional(),
|
|
126
|
+
});
|
|
127
|
+
export const SubsidiaryEnrichmentParamsSchema = z.object({
|
|
128
|
+
companyId: NonEmptyString,
|
|
129
|
+
filingId: NonEmptyString,
|
|
130
|
+
});
|
|
131
|
+
export const BusinessSegmentParamsSchema = z.object({
|
|
132
|
+
companyId: NonEmptyString,
|
|
133
|
+
segmentName: NonEmptyString,
|
|
134
|
+
fiscalYear: IntNumber,
|
|
135
|
+
fiscalQuarter: IntNumber.nullable(),
|
|
136
|
+
});
|
|
137
|
+
export const BrandParamsSchema = z.object({
|
|
138
|
+
companyId: NonEmptyString,
|
|
139
|
+
name: NonEmptyString,
|
|
140
|
+
});
|
|
141
|
+
export const OwnsParamsSchema = z.object({
|
|
142
|
+
companyId: NonEmptyString,
|
|
143
|
+
brandId: NonEmptyString,
|
|
144
|
+
});
|
|
145
|
+
// ============================================================================
|
|
146
|
+
// TYPE GUARDS
|
|
147
|
+
// ============================================================================
|
|
148
|
+
export function isPublicCompany(company) {
|
|
149
|
+
return (company.type === CompanyType.PUBLIC || company.type === CompanyType.ISSUER);
|
|
150
|
+
}
|
|
151
|
+
export function isPrivateCompany(company) {
|
|
152
|
+
return company.type === CompanyType.PRIVATE;
|
|
153
|
+
}
|
|
154
|
+
export function isFromSecFiling(edge) {
|
|
155
|
+
return edge.source === ParentOfSource.SEC_FILING;
|
|
156
|
+
}
|
|
157
|
+
// ============================================================================
|
|
158
|
+
// VALIDATION HELPERS
|
|
159
|
+
// ============================================================================
|
|
160
|
+
export function validate(schema, data, schemaName) {
|
|
161
|
+
try {
|
|
162
|
+
return schema.parse(data);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
if (error instanceof z.ZodError) {
|
|
166
|
+
const errors = error.issues
|
|
167
|
+
.map((e) => `${e.path.join(".")}: ${e.message}`)
|
|
168
|
+
.join(", ");
|
|
169
|
+
throw new Error(`Validation failed${schemaName ? ` for ${schemaName}` : ""}: ${errors}`);
|
|
170
|
+
}
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
export function safeValidate(schema, data) {
|
|
175
|
+
const result = schema.safeParse(data);
|
|
176
|
+
if (result.success) {
|
|
177
|
+
return { success: true, data: result.data };
|
|
178
|
+
}
|
|
179
|
+
return { success: false, error: result.error };
|
|
180
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Re-exports (backward compatibility)
|
|
3
|
+
*
|
|
4
|
+
* For new code, import directly from "./types"
|
|
5
|
+
*/
|
|
6
|
+
export { NonEmptyString, IntNumber, CIKString, JurisdictionString, CompanySchema, PublicCompanySchema, PrivateCompanySchema, IssuerCompanySchema, UnknownCompanySchema, AccessionNumberString, ParentOfParamsSchema, SubsidiaryEnrichmentParamsSchema, BusinessSegmentParamsSchema, BrandParamsSchema, OwnsParamsSchema, validate, safeValidate, } from "./types";
|
|
7
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../types/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,cAAc,EACd,SAAS,EACT,SAAS,EACT,kBAAkB,EAGlB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EAGpB,qBAAqB,EACrB,oBAAoB,EACpB,gCAAgC,EAChC,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EAGhB,QAAQ,EACR,YAAY,GACb,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Re-exports (backward compatibility)
|
|
3
|
+
*
|
|
4
|
+
* For new code, import directly from "./types"
|
|
5
|
+
*/
|
|
6
|
+
export {
|
|
7
|
+
// Field validators
|
|
8
|
+
NonEmptyString, IntNumber, CIKString, JurisdictionString,
|
|
9
|
+
// Company validation (type-specific rules)
|
|
10
|
+
CompanySchema, PublicCompanySchema, PrivateCompanySchema, IssuerCompanySchema, UnknownCompanySchema,
|
|
11
|
+
// ID generation params
|
|
12
|
+
AccessionNumberString, ParentOfParamsSchema, SubsidiaryEnrichmentParamsSchema, BusinessSegmentParamsSchema, BrandParamsSchema, OwnsParamsSchema,
|
|
13
|
+
// Helpers
|
|
14
|
+
validate, safeValidate, } from "./types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Logger Interface
|
|
3
|
+
*
|
|
4
|
+
* Common interface for logging across frontend and backend.
|
|
5
|
+
* Implementations differ (browser vs Node.js) but API is consistent.
|
|
6
|
+
*/
|
|
7
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
8
|
+
export interface LogMetadata {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface Logger {
|
|
12
|
+
debug(message: string, meta?: LogMetadata): void;
|
|
13
|
+
info(message: string, meta?: LogMetadata): void;
|
|
14
|
+
warn(message: string, meta?: LogMetadata): void;
|
|
15
|
+
error(message: string, meta?: LogMetadata): void;
|
|
16
|
+
}
|
|
17
|
+
export interface LoggerFactory {
|
|
18
|
+
createLogger(context: string): Logger;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Failed Record Utilities
|
|
22
|
+
*
|
|
23
|
+
* Convention for saving failed records during ingestion/processing.
|
|
24
|
+
* Failed records are separate from logs and stored in a structured format.
|
|
25
|
+
*/
|
|
26
|
+
export interface FailedRecord<T = any> {
|
|
27
|
+
timestamp: string;
|
|
28
|
+
context: string;
|
|
29
|
+
identifier: string | number;
|
|
30
|
+
data: T;
|
|
31
|
+
error: {
|
|
32
|
+
message: string;
|
|
33
|
+
stack?: string;
|
|
34
|
+
code?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface FailedRecordOptions {
|
|
38
|
+
/** Base directory for failed records (e.g., 'financial-graph/backend/logs/failed-records') */
|
|
39
|
+
baseDir: string;
|
|
40
|
+
/** Context/module name (e.g., 'ticker-ingestion', 'subsidiary-parser') */
|
|
41
|
+
context: string;
|
|
42
|
+
/** Optional date for organizing by date (defaults to today) */
|
|
43
|
+
date?: Date;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Generate a standardized path for failed records
|
|
47
|
+
*
|
|
48
|
+
* Convention: {baseDir}/{context}/{YYYY-MM-DD}/failed-{context}-{timestamp}.json
|
|
49
|
+
*
|
|
50
|
+
* Example: logs/failed-records/ticker-ingestion/2026-01-12/failed-ticker-ingestion-20260112-143022.json
|
|
51
|
+
*/
|
|
52
|
+
export declare function getFailedRecordPath(options: FailedRecordOptions): string;
|
|
53
|
+
/**
|
|
54
|
+
* Create a failed record object
|
|
55
|
+
*/
|
|
56
|
+
export declare function createFailedRecord<T>(context: string, identifier: string | number, data: T, error: Error | string): FailedRecord<T>;
|
|
57
|
+
//# sourceMappingURL=logger-interface.d.ts.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AC;CACb;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAMxE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,KAAK,GAAG,MAAM,GACpB,YAAY,CAAC,CAAC,CAAC,CAgBjB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Logger Interface
|
|
3
|
+
*
|
|
4
|
+
* Common interface for logging across frontend and backend.
|
|
5
|
+
* Implementations differ (browser vs Node.js) but API is consistent.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Generate a standardized path for failed records
|
|
9
|
+
*
|
|
10
|
+
* Convention: {baseDir}/{context}/{YYYY-MM-DD}/failed-{context}-{timestamp}.json
|
|
11
|
+
*
|
|
12
|
+
* Example: logs/failed-records/ticker-ingestion/2026-01-12/failed-ticker-ingestion-20260112-143022.json
|
|
13
|
+
*/
|
|
14
|
+
export function getFailedRecordPath(options) {
|
|
15
|
+
const date = options.date || new Date();
|
|
16
|
+
const dateStr = date.toISOString().split("T")[0]; // YYYY-MM-DD
|
|
17
|
+
const timestamp = date.toISOString().replace(/[:.]/g, "-").split("T").join("-").slice(0, -5); // YYYY-MM-DD-HHmmss
|
|
18
|
+
return `${options.baseDir}/${options.context}/${dateStr}/failed-${options.context}-${timestamp}.json`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a failed record object
|
|
22
|
+
*/
|
|
23
|
+
export function createFailedRecord(context, identifier, data, error) {
|
|
24
|
+
const errorObj = typeof error === "string"
|
|
25
|
+
? { message: error }
|
|
26
|
+
: {
|
|
27
|
+
message: error.message,
|
|
28
|
+
stack: error.stack,
|
|
29
|
+
code: error.code,
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
timestamp: new Date().toISOString(),
|
|
33
|
+
context,
|
|
34
|
+
identifier,
|
|
35
|
+
data,
|
|
36
|
+
error: errorObj,
|
|
37
|
+
};
|
|
38
|
+
}
|