@pipe2-ai/sdk 0.1.0 → 0.1.2

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.
@@ -35,12 +35,16 @@ export var Assets_Select_Column;
35
35
  /** column name */
36
36
  Assets_Select_Column["CreatedAt"] = "created_at";
37
37
  /** column name */
38
+ Assets_Select_Column["DurationSec"] = "duration_sec";
39
+ /** column name */
38
40
  Assets_Select_Column["Id"] = "id";
39
41
  /** column name */
40
42
  Assets_Select_Column["Metadata"] = "metadata";
41
43
  /** column name */
42
44
  Assets_Select_Column["PipelineRunId"] = "pipeline_run_id";
43
45
  /** column name */
46
+ Assets_Select_Column["PreviewFrames"] = "preview_frames";
47
+ /** column name */
44
48
  Assets_Select_Column["Tags"] = "tags";
45
49
  /** column name */
46
50
  Assets_Select_Column["ThumbnailUrl"] = "thumbnail_url";
@@ -93,6 +97,24 @@ export var Executions_Visibility_Select_Column;
93
97
  /** column name */
94
98
  Executions_Visibility_Select_Column["WorkflowTypeName"] = "workflow_type_name";
95
99
  })(Executions_Visibility_Select_Column || (Executions_Visibility_Select_Column = {}));
100
+ /** select columns of table "notifications" */
101
+ export var Notifications_Select_Column;
102
+ (function (Notifications_Select_Column) {
103
+ /** column name */
104
+ Notifications_Select_Column["Body"] = "body";
105
+ /** column name */
106
+ Notifications_Select_Column["CreatedAt"] = "created_at";
107
+ /** column name */
108
+ Notifications_Select_Column["Id"] = "id";
109
+ /** column name */
110
+ Notifications_Select_Column["Metadata"] = "metadata";
111
+ /** column name */
112
+ Notifications_Select_Column["Read"] = "read";
113
+ /** column name */
114
+ Notifications_Select_Column["Title"] = "title";
115
+ /** column name */
116
+ Notifications_Select_Column["Type"] = "type";
117
+ })(Notifications_Select_Column || (Notifications_Select_Column = {}));
96
118
  /** column ordering options */
97
119
  export var Order_By;
98
120
  (function (Order_By) {
@@ -157,24 +179,30 @@ export var Pipeline_Runs_Select_Column;
157
179
  export var Pipelines_Select_Column;
158
180
  (function (Pipelines_Select_Column) {
159
181
  /** column name */
160
- Pipelines_Select_Column["Category"] = "category";
182
+ Pipelines_Select_Column["Cancellable"] = "cancellable";
161
183
  /** column name */
162
- Pipelines_Select_Column["CreditCost"] = "credit_cost";
184
+ Pipelines_Select_Column["Category"] = "category";
163
185
  /** column name */
164
186
  Pipelines_Select_Column["Description"] = "description";
165
187
  /** column name */
188
+ Pipelines_Select_Column["Hints"] = "hints";
189
+ /** column name */
166
190
  Pipelines_Select_Column["IconUrl"] = "icon_url";
167
191
  /** column name */
168
192
  Pipelines_Select_Column["Id"] = "id";
169
193
  /** column name */
170
194
  Pipelines_Select_Column["InputSchema"] = "input_schema";
171
195
  /** column name */
196
+ Pipelines_Select_Column["IsActive"] = "is_active";
197
+ /** column name */
172
198
  Pipelines_Select_Column["Name"] = "name";
173
199
  /** column name */
174
200
  Pipelines_Select_Column["OutputSchema"] = "output_schema";
175
201
  /** column name */
176
202
  Pipelines_Select_Column["PreviewUrl"] = "preview_url";
177
203
  /** column name */
204
+ Pipelines_Select_Column["Pricing"] = "pricing";
205
+ /** column name */
178
206
  Pipelines_Select_Column["RequiredProviders"] = "required_providers";
179
207
  /** column name */
180
208
  Pipelines_Select_Column["SeoContent"] = "seo_content";
@@ -185,6 +213,8 @@ export var Pipelines_Select_Column;
185
213
  /** column name */
186
214
  Pipelines_Select_Column["SortOrder"] = "sort_order";
187
215
  /** column name */
216
+ Pipelines_Select_Column["Tags"] = "tags";
217
+ /** column name */
188
218
  Pipelines_Select_Column["UiSchema"] = "ui_schema";
189
219
  })(Pipelines_Select_Column || (Pipelines_Select_Column = {}));
190
220
  /** select columns of table "plans" */
@@ -227,6 +257,81 @@ export var Subscriptions_Select_Column;
227
257
  /** column name */
228
258
  Subscriptions_Select_Column["Status"] = "status";
229
259
  })(Subscriptions_Select_Column || (Subscriptions_Select_Column = {}));
260
+ export const ChangePasswordDocument = gql `
261
+ mutation ChangePassword($current_password: String!, $new_password: String!) {
262
+ change_password(
263
+ current_password: $current_password
264
+ new_password: $new_password
265
+ ) {
266
+ success
267
+ message
268
+ }
269
+ }
270
+ `;
271
+ export const ChangeNameDocument = gql `
272
+ mutation ChangeName($name: String!) {
273
+ change_name(name: $name) {
274
+ success
275
+ message
276
+ name
277
+ }
278
+ }
279
+ `;
280
+ export const CancelSubscriptionDocument = gql `
281
+ mutation CancelSubscription {
282
+ cancel_subscription {
283
+ success
284
+ message
285
+ cancel_at_period_end
286
+ }
287
+ }
288
+ `;
289
+ export const RequestAvatarUploadDocument = gql `
290
+ mutation RequestAvatarUpload($filename: String!, $content_type: String!) {
291
+ request_avatar_upload(filename: $filename, content_type: $content_type) {
292
+ success
293
+ upload_url
294
+ asset_url
295
+ key
296
+ max_size
297
+ }
298
+ }
299
+ `;
300
+ export const ChangeAvatarDocument = gql `
301
+ mutation ChangeAvatar($avatar_url: String!) {
302
+ change_avatar(avatar_url: $avatar_url) {
303
+ success
304
+ message
305
+ avatar_url
306
+ }
307
+ }
308
+ `;
309
+ export const RequestAccountDeletionDocument = gql `
310
+ mutation RequestAccountDeletion {
311
+ request_account_deletion {
312
+ success
313
+ message
314
+ expires_at
315
+ }
316
+ }
317
+ `;
318
+ export const ConfirmAccountDeletionDocument = gql `
319
+ mutation ConfirmAccountDeletion($token: String!) {
320
+ confirm_account_deletion(token: $token) {
321
+ success
322
+ message
323
+ effective_at
324
+ }
325
+ }
326
+ `;
327
+ export const CancelAccountDeletionDocument = gql `
328
+ mutation CancelAccountDeletion {
329
+ cancel_account_deletion {
330
+ success
331
+ message
332
+ }
333
+ }
334
+ `;
230
335
  export const GetMyAffiliateCodesDocument = gql `
231
336
  query GetMyAffiliateCodes {
232
337
  affiliate_codes(order_by: {created_at: desc}) {
@@ -289,6 +394,28 @@ export const GetMyReferralsDocument = gql `
289
394
  }
290
395
  }
291
396
  `;
397
+ export const GetAssetThumbnailDocument = gql `
398
+ query GetAssetThumbnail($id: uuid!) {
399
+ assets_by_pk(id: $id) {
400
+ id
401
+ type
402
+ url
403
+ thumbnail_url
404
+ preview_frames
405
+ }
406
+ }
407
+ `;
408
+ export const GetAssetThumbnailsByIdsDocument = gql `
409
+ query GetAssetThumbnailsByIds($ids: [uuid!]!) {
410
+ assets(where: {id: {_in: $ids}}) {
411
+ id
412
+ type
413
+ url
414
+ thumbnail_url
415
+ preview_frames
416
+ }
417
+ }
418
+ `;
292
419
  export const GetUserAssetsDocument = gql `
293
420
  query GetUserAssets($where: assets_bool_exp = {}, $limit: Int = 20, $offset: Int = 0) {
294
421
  assets(
@@ -301,6 +428,7 @@ export const GetUserAssetsDocument = gql `
301
428
  type
302
429
  url
303
430
  thumbnail_url
431
+ preview_frames
304
432
  metadata
305
433
  tags
306
434
  created_at
@@ -404,8 +532,8 @@ export const SubmitSocialLoginDocument = gql `
404
532
  }
405
533
  `;
406
534
  export const InitVerificationFlowDocument = gql `
407
- mutation InitVerificationFlow($email: String) {
408
- init_verification_flow(email: $email) {
535
+ mutation InitVerificationFlow($email: String, $force: Boolean) {
536
+ init_verification_flow(email: $email, force: $force) {
409
537
  id
410
538
  csrf_token
411
539
  }
@@ -458,9 +586,42 @@ export const GetCreditHistoryDocument = gql `
458
586
  }
459
587
  }
460
588
  `;
589
+ export const GetNotificationsDocument = gql `
590
+ query GetNotifications($limit: Int!, $offset: Int!) {
591
+ notifications(order_by: {created_at: desc}, limit: $limit, offset: $offset) {
592
+ id
593
+ type
594
+ title
595
+ body
596
+ metadata
597
+ read
598
+ created_at
599
+ }
600
+ unread: notifications_aggregate(where: {read: {_eq: false}}) {
601
+ aggregate {
602
+ count
603
+ }
604
+ }
605
+ }
606
+ `;
607
+ export const MarkNotificationReadDocument = gql `
608
+ mutation MarkNotificationRead($id: uuid!) {
609
+ update_notifications_by_pk(pk_columns: {id: $id}, _set: {read: true}) {
610
+ id
611
+ read
612
+ }
613
+ }
614
+ `;
615
+ export const MarkAllNotificationsReadDocument = gql `
616
+ mutation MarkAllNotificationsRead {
617
+ update_notifications(where: {read: {_eq: false}}, _set: {read: true}) {
618
+ affected_rows
619
+ }
620
+ }
621
+ `;
461
622
  export const GetPipelinesDocument = gql `
462
623
  query GetPipelines {
463
- pipelines(order_by: {sort_order: asc}) {
624
+ pipelines(where: {is_active: {_eq: true}}, order_by: {sort_order: asc}) {
464
625
  id
465
626
  slug
466
627
  name
@@ -469,12 +630,15 @@ export const GetPipelinesDocument = gql `
469
630
  icon_url
470
631
  preview_url
471
632
  required_providers
472
- credit_cost
473
633
  input_schema
474
634
  ui_schema
475
635
  output_schema
476
636
  seo_content
477
637
  seo_faq
638
+ tags
639
+ hints
640
+ pricing
641
+ cancellable
478
642
  }
479
643
  }
480
644
  `;
@@ -486,11 +650,19 @@ export const RunPipelineDocument = gql `
486
650
  }
487
651
  }
488
652
  `;
653
+ export const CancelPipelineRunDocument = gql `
654
+ mutation CancelPipelineRun($run_id: String!) {
655
+ cancel_pipeline_run(run_id: $run_id) {
656
+ success
657
+ }
658
+ }
659
+ `;
489
660
  export const GetPipelineRunDocument = gql `
490
661
  query GetPipelineRun($id: uuid!) {
491
662
  pipeline_runs_by_pk(id: $id) {
492
663
  id
493
664
  status
665
+ input
494
666
  output
495
667
  error_message
496
668
  credits_charged
@@ -500,6 +672,8 @@ export const GetPipelineRunDocument = gql `
500
672
  name
501
673
  slug
502
674
  output_schema
675
+ input_schema
676
+ ui_schema
503
677
  }
504
678
  assets {
505
679
  id
@@ -529,27 +703,35 @@ export const GetPipelineRunsDocument = gql `
529
703
  name
530
704
  slug
531
705
  output_schema
706
+ input_schema
707
+ ui_schema
532
708
  }
533
709
  status
710
+ input
534
711
  output
535
712
  error_message
536
713
  credits_charged
537
714
  created_at
538
715
  completed_at
716
+ workflow_execution {
717
+ status
718
+ start_time
719
+ close_time
720
+ }
539
721
  }
540
722
  pipeline_runs_aggregate(where: $where) {
541
723
  aggregate {
542
724
  count
543
- sum {
544
- credits_charged
545
- }
546
725
  }
547
726
  }
548
727
  completed: pipeline_runs_aggregate(
549
- where: {_and: [$where, {completed_at: {_is_null: false}}]}
728
+ where: {_and: [$where, {status: {_eq: "completed"}}]}
550
729
  ) {
551
730
  aggregate {
552
731
  count
732
+ sum {
733
+ credits_charged
734
+ }
553
735
  }
554
736
  }
555
737
  }
@@ -568,12 +750,21 @@ export const GetPipelineRunsBySlugDocument = gql `
568
750
  name
569
751
  slug
570
752
  output_schema
753
+ input_schema
754
+ ui_schema
571
755
  }
756
+ input
572
757
  output
573
758
  error_message
574
759
  credits_charged
575
760
  created_at
576
761
  completed_at
762
+ assets {
763
+ id
764
+ type
765
+ url
766
+ thumbnail_url
767
+ }
577
768
  workflow_execution {
578
769
  status
579
770
  start_time
@@ -587,6 +778,30 @@ export const GetPipelineRunsBySlugDocument = gql `
587
778
  }
588
779
  }
589
780
  `;
781
+ export const GetActivePipelineRunsDocument = gql `
782
+ query GetActivePipelineRuns {
783
+ pipeline_runs(
784
+ where: {status: {_in: ["pending", "running"]}}
785
+ order_by: {created_at: desc}
786
+ limit: 10
787
+ ) {
788
+ id
789
+ status
790
+ created_at
791
+ pipeline {
792
+ name
793
+ slug
794
+ }
795
+ }
796
+ active_count: pipeline_runs_aggregate(
797
+ where: {status: {_in: ["pending", "running"]}}
798
+ ) {
799
+ aggregate {
800
+ count
801
+ }
802
+ }
803
+ }
804
+ `;
590
805
  export const GetPlansDocument = gql `
591
806
  query GetPlans {
592
807
  plans(order_by: {sort_order: asc}) {
@@ -638,12 +853,18 @@ export const WatchPipelineRunDocument = gql `
638
853
  pipeline_runs_by_pk(id: $run_id) {
639
854
  id
640
855
  status
856
+ input
641
857
  output
642
858
  error_message
859
+ credits_charged
860
+ created_at
643
861
  completed_at
644
862
  pipeline {
645
863
  name
646
864
  slug
865
+ output_schema
866
+ input_schema
867
+ ui_schema
647
868
  }
648
869
  assets {
649
870
  id
@@ -654,6 +875,36 @@ export const WatchPipelineRunDocument = gql `
654
875
  }
655
876
  }
656
877
  `;
878
+ export const WatchActivePipelineRunsDocument = gql `
879
+ subscription WatchActivePipelineRuns {
880
+ pipeline_runs(
881
+ where: {status: {_in: ["pending", "running"]}}
882
+ order_by: {created_at: desc}
883
+ limit: 10
884
+ ) {
885
+ id
886
+ status
887
+ created_at
888
+ pipeline {
889
+ name
890
+ slug
891
+ }
892
+ }
893
+ }
894
+ `;
895
+ export const WatchNotificationsDocument = gql `
896
+ subscription WatchNotifications($limit: Int!) {
897
+ notifications(order_by: {created_at: desc}, limit: $limit) {
898
+ id
899
+ type
900
+ title
901
+ body
902
+ metadata
903
+ read
904
+ created_at
905
+ }
906
+ }
907
+ `;
657
908
  export const GetMyApiKeysDocument = gql `
658
909
  query GetMyApiKeys {
659
910
  personal_access_tokens(order_by: {created_at: desc}) {
@@ -694,11 +945,37 @@ export const GetCurrentUserDocument = gql `
694
945
  name
695
946
  email_verified
696
947
  avatar_url
948
+ deletion_scheduled_at
949
+ deletion_effective_at
697
950
  }
698
951
  }
699
952
  `;
700
953
  export function getSdk(requester) {
701
954
  return {
955
+ ChangePassword(variables, options) {
956
+ return requester(ChangePasswordDocument, variables, options);
957
+ },
958
+ ChangeName(variables, options) {
959
+ return requester(ChangeNameDocument, variables, options);
960
+ },
961
+ CancelSubscription(variables, options) {
962
+ return requester(CancelSubscriptionDocument, variables, options);
963
+ },
964
+ RequestAvatarUpload(variables, options) {
965
+ return requester(RequestAvatarUploadDocument, variables, options);
966
+ },
967
+ ChangeAvatar(variables, options) {
968
+ return requester(ChangeAvatarDocument, variables, options);
969
+ },
970
+ RequestAccountDeletion(variables, options) {
971
+ return requester(RequestAccountDeletionDocument, variables, options);
972
+ },
973
+ ConfirmAccountDeletion(variables, options) {
974
+ return requester(ConfirmAccountDeletionDocument, variables, options);
975
+ },
976
+ CancelAccountDeletion(variables, options) {
977
+ return requester(CancelAccountDeletionDocument, variables, options);
978
+ },
702
979
  GetMyAffiliateCodes(variables, options) {
703
980
  return requester(GetMyAffiliateCodesDocument, variables, options);
704
981
  },
@@ -714,6 +991,12 @@ export function getSdk(requester) {
714
991
  GetMyReferrals(variables, options) {
715
992
  return requester(GetMyReferralsDocument, variables, options);
716
993
  },
994
+ GetAssetThumbnail(variables, options) {
995
+ return requester(GetAssetThumbnailDocument, variables, options);
996
+ },
997
+ GetAssetThumbnailsByIds(variables, options) {
998
+ return requester(GetAssetThumbnailsByIdsDocument, variables, options);
999
+ },
717
1000
  GetUserAssets(variables, options) {
718
1001
  return requester(GetUserAssetsDocument, variables, options);
719
1002
  },
@@ -762,12 +1045,24 @@ export function getSdk(requester) {
762
1045
  GetCreditHistory(variables, options) {
763
1046
  return requester(GetCreditHistoryDocument, variables, options);
764
1047
  },
1048
+ GetNotifications(variables, options) {
1049
+ return requester(GetNotificationsDocument, variables, options);
1050
+ },
1051
+ MarkNotificationRead(variables, options) {
1052
+ return requester(MarkNotificationReadDocument, variables, options);
1053
+ },
1054
+ MarkAllNotificationsRead(variables, options) {
1055
+ return requester(MarkAllNotificationsReadDocument, variables, options);
1056
+ },
765
1057
  GetPipelines(variables, options) {
766
1058
  return requester(GetPipelinesDocument, variables, options);
767
1059
  },
768
1060
  RunPipeline(variables, options) {
769
1061
  return requester(RunPipelineDocument, variables, options);
770
1062
  },
1063
+ CancelPipelineRun(variables, options) {
1064
+ return requester(CancelPipelineRunDocument, variables, options);
1065
+ },
771
1066
  GetPipelineRun(variables, options) {
772
1067
  return requester(GetPipelineRunDocument, variables, options);
773
1068
  },
@@ -777,6 +1072,9 @@ export function getSdk(requester) {
777
1072
  GetPipelineRunsBySlug(variables, options) {
778
1073
  return requester(GetPipelineRunsBySlugDocument, variables, options);
779
1074
  },
1075
+ GetActivePipelineRuns(variables, options) {
1076
+ return requester(GetActivePipelineRunsDocument, variables, options);
1077
+ },
780
1078
  GetPlans(variables, options) {
781
1079
  return requester(GetPlansDocument, variables, options);
782
1080
  },
@@ -789,6 +1087,12 @@ export function getSdk(requester) {
789
1087
  WatchPipelineRun(variables, options) {
790
1088
  return requester(WatchPipelineRunDocument, variables, options);
791
1089
  },
1090
+ WatchActivePipelineRuns(variables, options) {
1091
+ return requester(WatchActivePipelineRunsDocument, variables, options);
1092
+ },
1093
+ WatchNotifications(variables, options) {
1094
+ return requester(WatchNotificationsDocument, variables, options);
1095
+ },
792
1096
  GetMyApiKeys(variables, options) {
793
1097
  return requester(GetMyApiKeysDocument, variables, options);
794
1098
  },
@@ -4,5 +4,5 @@ export type Pipe2SDK = ReturnType<typeof getSdk>;
4
4
  * Create a Pipe2.ai SDK client with full support for queries, mutations,
5
5
  * and real-time WebSocket subscriptions.
6
6
  */
7
- export declare function createClient(token: string, endpoint?: string): Pipe2SDK;
7
+ export declare function createClient(token: string, endpoint?: string, wsEndpoint?: string): Pipe2SDK;
8
8
  export * from '../generated/sdk.js';
package/dist/src/index.js CHANGED
@@ -1,28 +1,31 @@
1
1
  import { GraphQLClient } from 'graphql-request';
2
2
  import { createClient as createWsClient } from 'graphql-ws';
3
3
  import { print } from 'graphql';
4
- import WebSocket from 'ws';
5
4
  import { getSdk } from '../generated/sdk.js';
6
5
  /**
7
6
  * Create a Pipe2.ai SDK client with full support for queries, mutations,
8
7
  * and real-time WebSocket subscriptions.
9
8
  */
10
- export function createClient(token, endpoint = 'https://api.pipe2.ai/v1/graphql') {
9
+ export function createClient(token, endpoint = 'https://api.pipe2.ai/v1/graphql', wsEndpoint) {
11
10
  const headers = {};
12
11
  if (token) {
13
12
  headers.Authorization = `Bearer ${token}`;
14
13
  }
15
14
  // HTTP client for queries and mutations
16
15
  const httpClient = new GraphQLClient(endpoint, { headers });
17
- // WebSocket client for subscriptions (lazy — connects on first subscription)
18
- const wsEndpoint = endpoint.replace(/^http/, 'ws');
16
+ // WebSocket client for subscriptions (lazy — connects on first subscription).
17
+ // wsEndpoint overrides the derived URL — needed in dev because Astro's
18
+ // dev-server doesn't proxy WS upgrades through Vite, so subscriptions must
19
+ // bypass the same-origin proxy and dial Hasura directly.
20
+ const wsEndpointResolved = wsEndpoint || endpoint.replace(/^http/, 'ws');
19
21
  let wsClient = null;
20
22
  const getWsClient = () => {
21
23
  if (!wsClient) {
22
24
  wsClient = createWsClient({
23
- url: wsEndpoint,
25
+ url: wsEndpointResolved,
24
26
  connectionParams: { headers },
25
- webSocketImpl: WebSocket,
27
+ // Browsers have native WebSocket; only Node.js needs the 'ws' polyfill.
28
+ // graphql-ws uses globalThis.WebSocket by default when webSocketImpl is omitted.
26
29
  });
27
30
  }
28
31
  return wsClient;
package/package.json CHANGED
@@ -1,9 +1,19 @@
1
1
  {
2
2
  "name": "@pipe2-ai/sdk",
3
- "version": "0.1.0",
4
- "main": "dist/src/index.js",
5
- "types": "dist/src/index.d.ts",
6
- "files": ["dist"],
3
+ "version": "0.1.2",
4
+ "type": "module",
5
+ "main": "./dist/src/index.js",
6
+ "types": "./dist/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/src/index.d.ts",
10
+ "import": "./dist/src/index.js",
11
+ "default": "./dist/src/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
7
17
  "scripts": {
8
18
  "codegen": "graphql-codegen --config codegen.ts",
9
19
  "build": "bun run codegen && tsc"