@pylo/node 0.0.9 → 0.0.11

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/cli.js CHANGED
@@ -407,9 +407,14 @@ function generateEntitiesFile(entities, importSource) {
407
407
  lines.push(
408
408
  "// Auto-generated by @pylo/core codegen \u2014 DO NOT EDIT",
409
409
  "",
410
- `import type { PaginationData } from '${importSource}';`,
411
- ""
410
+ `import type { PaginationData } from '${importSource}';`
412
411
  );
412
+ const enumTypes = collectEnumTypes(entities);
413
+ if (enumTypes.length > 0) {
414
+ const names = enumTypes.map((e) => e.typeName).join(", ");
415
+ lines.push(`import type { ${names} } from './index.js';`);
416
+ }
417
+ lines.push("");
413
418
  for (const entity of entities) {
414
419
  lines.push(`export interface ${entity.pascalName} {`);
415
420
  for (const field of entity.fields) {
package/dist/index.d.ts CHANGED
@@ -38,10 +38,20 @@ interface SearchValueInput {
38
38
  multiple_results_allowed?: boolean;
39
39
  multiple_results_use_latest?: boolean;
40
40
  }
41
+ interface PyloEventInput {
42
+ event_name: string;
43
+ properties: Record<string, unknown>;
44
+ }
45
+ interface PyloEvent {
46
+ event_name: string;
47
+ ts: string;
48
+ properties: Record<string, unknown>;
49
+ }
41
50
  interface EntityMetadata {
42
51
  pascalName: string;
43
52
  scalarFieldNames: string[];
44
53
  variantFieldNames?: string[];
54
+ jsonFieldNames?: string[];
45
55
  enumFields?: Record<string, string[]>;
46
56
  relations: Record<string, {
47
57
  type: "hasOne" | "hasMany";
@@ -164,8 +174,11 @@ interface EntityClient<S, E extends EntityName<S>> {
164
174
  success: boolean;
165
175
  }>;
166
176
  }
177
+ type IngestEvents = (events: PyloEventInput[], options?: MutationRequestOptions) => Promise<PyloEvent[]>;
167
178
  type PyloClient<S> = {
168
179
  [E in EntityName<S>]: EntityClient<S, E>;
180
+ } & {
181
+ ingestEvents: IngestEvents;
169
182
  };
170
183
 
171
184
  interface NodeClientOptions {
@@ -176,4 +189,4 @@ interface NodeClientOptions {
176
189
  }
177
190
  declare function createPyloNode<S>(options: NodeClientOptions): PyloClient<S>;
178
191
 
179
- export { type AuthProvider, type ByIdOptions, type ClientOptions, type EntityClient, type EntityFields, type EntityMetadata, type EntityName, type EntityRelations, type EntityResult, type EntitySelect, type FilterInput, type ListOptions, type ListResult, type PaginationData, type PaginationInput, type PyloClient, PyloError, type QueryInput, type QueryInputCondition, type QueryOperator, type RequestOptions, type SchemaMetadata, type SearchValueInput, type SortInput, type SortOrder, type StrictSelect, type UpsertInput, createPyloNode };
192
+ export { type AuthProvider, type ByIdOptions, type ClientOptions, type EntityClient, type EntityFields, type EntityMetadata, type EntityName, type EntityRelations, type EntityResult, type EntitySelect, type FilterInput, type IngestEvents, type ListOptions, type ListResult, type MutationRequestOptions, type PaginationData, type PaginationInput, type PyloClient, PyloError, type PyloEvent, type PyloEventInput, type QueryInput, type QueryInputCondition, type QueryOperator, type RequestOptions, type SchemaMetadata, type SearchValueInput, type SortInput, type SortOrder, type StrictSelect, type UpsertInput, createPyloNode };
package/dist/index.js CHANGED
@@ -234,6 +234,21 @@ function buildDeleteMutation(_entityKey, pascalName, ids) {
234
234
  variables: { ids }
235
235
  };
236
236
  }
237
+ function buildIngestEventsMutation(events) {
238
+ const mutation = `mutation IngestPyloEventData($input: [PyloEventInput!]!) {
239
+ ingestPyloEventData(input: $input) {
240
+ data {
241
+ event_name
242
+ ts
243
+ properties
244
+ }
245
+ }
246
+ }`;
247
+ return {
248
+ query: mutation,
249
+ variables: { input: events }
250
+ };
251
+ }
237
252
  var PYLO_DRY_RUN_HEADER = "pylo-dry-run";
238
253
  var PYLO_DO_NOT_TRIGGER_FLOWS_HEADER = "pylo-do-not-trigger-flow";
239
254
  function flagsToHeaders(flags) {
@@ -368,14 +383,36 @@ function createEntityClient(entityKey, endpoint, metadata, auth, globalHeaders)
368
383
  }
369
384
  };
370
385
  }
386
+ function createIngestEvents(endpoint, auth, globalHeaders) {
387
+ return async (events, options) => {
388
+ const { query, variables } = buildIngestEventsMutation(events);
389
+ const data = await executeGraphQL(
390
+ endpoint,
391
+ query,
392
+ variables,
393
+ auth,
394
+ mergeHeaders(
395
+ mergeHeaders(globalHeaders, options == null ? void 0 : options.headers),
396
+ flagsToHeaders(options != null ? options : {})
397
+ )
398
+ );
399
+ const result = data["ingestPyloEventData"];
400
+ if (!result) {
401
+ throw new PyloError("Unexpected response shape \u2014 missing ingestPyloEventData");
402
+ }
403
+ return result.data;
404
+ };
405
+ }
371
406
  function createPyloClient(options) {
372
407
  const endpoint = getEndpoint(options.endpoint);
373
408
  const metadata = options.schemaMetadata;
374
409
  const auth = options.auth;
375
410
  const globalHeaders = options.headers;
411
+ const ingestEvents = createIngestEvents(endpoint, auth, globalHeaders);
376
412
  return new Proxy({}, {
377
413
  get(_target, prop) {
378
414
  if (typeof prop !== "string") return void 0;
415
+ if (prop === "ingestEvents") return ingestEvents;
379
416
  return createEntityClient(prop, endpoint, metadata, auth, globalHeaders);
380
417
  }
381
418
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pylo/node",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Server-side Pylo SDK with API key authentication",
5
5
  "exports": {
6
6
  ".": {
@@ -19,7 +19,8 @@
19
19
  "pylo": "dist/cli.js"
20
20
  },
21
21
  "files": [
22
- "dist"
22
+ "dist",
23
+ "LICENSE"
23
24
  ],
24
25
  "dependencies": {
25
26
  "jiti": "^2.6.1"
@@ -28,10 +29,20 @@
28
29
  "@types/node": "^22.15.21",
29
30
  "tsup": "^8.5.1",
30
31
  "typescript": "^5.9.3",
31
- "@pylo/core": "0.0.11",
32
- "@pylo/auth": "0.0.4"
32
+ "@pylo/auth": "0.0.5",
33
+ "@pylo/core": "0.0.13"
34
+ },
35
+ "author": "Okeano GmbH",
36
+ "license": "MIT",
37
+ "homepage": "https://github.com/Okeano-GmbH/pylo-sdks/tree/main/node#readme",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/Okeano-GmbH/pylo-sdks.git",
41
+ "directory": "node"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/Okeano-GmbH/pylo-sdks/issues"
33
45
  },
34
- "license": "ISC",
35
46
  "scripts": {
36
47
  "build": "tsup",
37
48
  "watch": "tsc -w"