@upstart.gg/sdk 0.0.134 → 0.0.136
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/shared/ai/schemas.d.ts +11 -3
- package/dist/shared/ai/schemas.d.ts.map +1 -1
- package/dist/shared/ai/schemas.js +63 -1
- package/dist/shared/ai/schemas.js.map +1 -1
- package/dist/shared/ai/types.d.ts +138 -64
- package/dist/shared/ai/types.d.ts.map +1 -1
- package/dist/shared/ajv.js +6861 -1
- package/dist/shared/ajv.js.map +1 -1
- package/dist/shared/analytics/init.js +20 -1
- package/dist/shared/analytics/init.js.map +1 -1
- package/dist/shared/analytics/track.js +24 -1
- package/dist/shared/analytics/track.js.map +1 -1
- package/dist/shared/attributes.d.ts +99 -30
- package/dist/shared/attributes.d.ts.map +1 -1
- package/dist/shared/attributes.js +46 -1
- package/dist/shared/brick-manifest.d.ts +1 -1
- package/dist/shared/brick-manifest.js +26 -1
- package/dist/shared/bricks/manifests/_types.d.ts +9 -0
- package/dist/shared/bricks/manifests/_types.d.ts.map +1 -0
- package/dist/shared/bricks/{props/enum.js → manifests/_types.js} +1 -2
- package/dist/shared/bricks/manifests/accordion.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/accordion.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/accordion.manifest.js +29 -1
- package/dist/shared/bricks/manifests/all-manifests.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/all-manifests.js +59 -1
- package/dist/shared/bricks/manifests/box.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/box.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/box.manifest.js +28 -1
- package/dist/shared/bricks/manifests/button.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/button.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/button.manifest.js +28 -1
- package/dist/shared/bricks/manifests/card.manifest.d.ts +10 -9
- package/dist/shared/bricks/manifests/card.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/card.manifest.js +28 -1
- package/dist/shared/bricks/manifests/carousel.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/carousel.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/carousel.manifest.js +28 -1
- package/dist/shared/bricks/manifests/footer.manifest.d.ts +6 -10
- package/dist/shared/bricks/manifests/footer.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/footer.manifest.js +30 -1
- package/dist/shared/bricks/manifests/form.manifest.d.ts +5 -9
- package/dist/shared/bricks/manifests/form.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/form.manifest.js +29 -1
- package/dist/shared/bricks/manifests/hero.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/hero.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/hero.manifest.js +28 -1
- package/dist/shared/bricks/manifests/html.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/html.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/html.manifest.js +28 -1
- package/dist/shared/bricks/manifests/icon.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/icon.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/icon.manifest.js +28 -1
- package/dist/shared/bricks/manifests/image.manifest.d.ts +3 -2
- package/dist/shared/bricks/manifests/image.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/image.manifest.js +28 -1
- package/dist/shared/bricks/manifests/images-gallery.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/images-gallery.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/images-gallery.manifest.js +28 -1
- package/dist/shared/bricks/manifests/map.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/map.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/map.manifest.js +31 -1
- package/dist/shared/bricks/manifests/navbar.manifest.d.ts +6 -10
- package/dist/shared/bricks/manifests/navbar.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/navbar.manifest.js +31 -1
- package/dist/shared/bricks/manifests/sidebar.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/sidebar.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/sidebar.manifest.js +29 -1
- package/dist/shared/bricks/manifests/social-links.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/social-links.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/social-links.manifest.js +28 -1
- package/dist/shared/bricks/manifests/spacer.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/spacer.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/spacer.manifest.js +28 -1
- package/dist/shared/bricks/manifests/table.manifest.d.ts +87 -0
- package/dist/shared/bricks/manifests/table.manifest.d.ts.map +1 -0
- package/dist/shared/bricks/manifests/table.manifest.js +31 -0
- package/dist/shared/bricks/manifests/table.manifest.js.map +1 -0
- package/dist/shared/bricks/manifests/tabs.manifest.d.ts +86 -0
- package/dist/shared/bricks/manifests/tabs.manifest.d.ts.map +1 -0
- package/dist/shared/bricks/manifests/tabs.manifest.js +31 -0
- package/dist/shared/bricks/manifests/tabs.manifest.js.map +1 -0
- package/dist/shared/bricks/manifests/testimonials.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/testimonials.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/testimonials.manifest.js +28 -1
- package/dist/shared/bricks/manifests/text.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/text.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/text.manifest.js +28 -1
- package/dist/shared/bricks/manifests/timeline.manifest.d.ts +97 -0
- package/dist/shared/bricks/manifests/timeline.manifest.d.ts.map +1 -0
- package/dist/shared/bricks/manifests/timeline.manifest.js +31 -0
- package/dist/shared/bricks/manifests/timeline.manifest.js.map +1 -0
- package/dist/shared/bricks/manifests/video.manifest.d.ts +4 -8
- package/dist/shared/bricks/manifests/video.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/video.manifest.js +28 -1
- package/dist/shared/bricks/props/align.d.ts +2 -2
- package/dist/shared/bricks/props/align.js +19 -1
- package/dist/shared/bricks/props/background.d.ts +4 -4
- package/dist/shared/bricks/props/background.js +15 -1
- package/dist/shared/bricks/props/boolean.js +7 -1
- package/dist/shared/bricks/props/border.js +16 -1
- package/dist/shared/bricks/props/color-preset.d.ts.map +1 -1
- package/dist/shared/bricks/props/color-preset.js +13 -1
- package/dist/shared/bricks/props/color.js +14 -1
- package/dist/shared/bricks/props/common.d.ts +2 -2
- package/dist/shared/bricks/props/common.js +13 -1
- package/dist/shared/bricks/props/css-length.js +14 -1
- package/dist/shared/bricks/props/datarecord.js +7 -1
- package/dist/shared/bricks/props/datasource.d.ts +1 -1
- package/dist/shared/bricks/props/datasource.js +86 -1
- package/dist/shared/bricks/props/datasource.js.map +1 -1
- package/dist/shared/bricks/props/date.js +9 -1
- package/dist/shared/bricks/props/direction.js +11 -1
- package/dist/shared/bricks/props/dynamic.d.ts.map +1 -1
- package/dist/shared/bricks/props/dynamic.js +30 -1
- package/dist/shared/bricks/props/effects.js +17 -1
- package/dist/shared/bricks/props/file.js +15 -1
- package/dist/shared/bricks/props/file.js.map +1 -1
- package/dist/shared/bricks/props/geolocation.js +44 -1
- package/dist/shared/bricks/props/geolocation.js.map +1 -1
- package/dist/shared/bricks/props/helpers.d.ts +1 -1
- package/dist/shared/bricks/props/helpers.js +18 -1
- package/dist/shared/bricks/props/image.js +11 -1
- package/dist/shared/bricks/props/number.js +7 -1
- package/dist/shared/bricks/props/position.js +7 -1
- package/dist/shared/bricks/props/string.js +18 -1
- package/dist/shared/bricks/props/tags.js +10 -1
- package/dist/shared/bricks/props/text.js +19 -1
- package/dist/shared/bricks.d.ts +59 -45
- package/dist/shared/bricks.d.ts.map +1 -1
- package/dist/shared/bricks.js +81 -1
- package/dist/shared/chunk-2BPYOTKA.js +21 -0
- package/dist/shared/{chunk-WHTPGWUV.js.map → chunk-2BPYOTKA.js.map} +1 -1
- package/dist/shared/chunk-2IHKVMKW.js +105 -0
- package/dist/shared/chunk-2IHKVMKW.js.map +1 -0
- package/dist/shared/chunk-2RK3CPYJ.js +74 -0
- package/dist/shared/{chunk-W33JMRRN.js.map → chunk-2RK3CPYJ.js.map} +1 -1
- package/dist/shared/chunk-2VDR4ZYY.js +230 -0
- package/dist/shared/chunk-2VDR4ZYY.js.map +1 -0
- package/dist/shared/chunk-36PLZKMW.js +538 -0
- package/dist/shared/chunk-36PLZKMW.js.map +1 -0
- package/dist/shared/chunk-3ZDN5BWN.js +18 -0
- package/dist/shared/{chunk-OIY3EPHO.js.map → chunk-3ZDN5BWN.js.map} +1 -1
- package/dist/shared/chunk-42OUNI7C.js +366 -0
- package/dist/shared/chunk-42OUNI7C.js.map +1 -0
- package/dist/shared/chunk-4MNWMEMM.js +422 -0
- package/dist/shared/chunk-4MNWMEMM.js.map +1 -0
- package/dist/shared/chunk-55C6MTX2.js +21 -0
- package/dist/shared/{chunk-KBHDY425.js.map → chunk-55C6MTX2.js.map} +1 -1
- package/dist/shared/chunk-6TVVKUWM.js +15 -0
- package/dist/shared/{chunk-4WDWJA3N.js.map → chunk-6TVVKUWM.js.map} +1 -1
- package/dist/shared/chunk-6WIMWLCJ.js +17 -0
- package/dist/shared/{chunk-KYY3PHP7.js.map → chunk-6WIMWLCJ.js.map} +1 -1
- package/dist/shared/chunk-7LAWWRU7.js +21 -0
- package/dist/shared/{chunk-IUXCWWGO.js.map → chunk-7LAWWRU7.js.map} +1 -1
- package/dist/shared/chunk-A2QPY54H.js +13 -0
- package/dist/shared/{chunk-KFM6KXSE.js.map → chunk-A2QPY54H.js.map} +1 -1
- package/dist/shared/chunk-BHC2A43S.js +67 -0
- package/dist/shared/{chunk-3YVJ2ELD.js.map → chunk-BHC2A43S.js.map} +1 -1
- package/dist/shared/chunk-BPBKHEQ5.js +39 -0
- package/dist/shared/{chunk-OHNYCXPX.js.map → chunk-BPBKHEQ5.js.map} +1 -1
- package/dist/shared/chunk-CRS7QCPZ.js +308 -0
- package/dist/shared/chunk-CRS7QCPZ.js.map +1 -0
- package/dist/shared/chunk-CSF2WQX2.js +60 -0
- package/dist/shared/{chunk-GLS7HPIZ.js.map → chunk-CSF2WQX2.js.map} +1 -1
- package/dist/shared/chunk-DFAFDBYZ.js +462 -0
- package/dist/shared/chunk-DFAFDBYZ.js.map +1 -0
- package/dist/shared/chunk-DV3G7X34.js +244 -0
- package/dist/shared/chunk-DV3G7X34.js.map +1 -0
- package/dist/shared/chunk-EVLRH6VG.js +56 -0
- package/dist/shared/{chunk-RJYZ5FAR.js.map → chunk-EVLRH6VG.js.map} +1 -1
- package/dist/shared/chunk-F22LDHEO.js +105 -0
- package/dist/shared/{chunk-5YRC3IT3.js.map → chunk-F22LDHEO.js.map} +1 -1
- package/dist/shared/chunk-F247VKAE.js +131 -0
- package/dist/shared/chunk-F247VKAE.js.map +1 -0
- package/dist/shared/chunk-FOGAVJC2.js +59 -0
- package/dist/shared/chunk-FOGAVJC2.js.map +1 -0
- package/dist/shared/chunk-FQDR2BBZ.js +30 -0
- package/dist/shared/chunk-FQDR2BBZ.js.map +1 -0
- package/dist/shared/chunk-GFAQWQER.js +618 -0
- package/dist/shared/chunk-GFAQWQER.js.map +1 -0
- package/dist/shared/chunk-GIGFNQBO.js +129 -0
- package/dist/shared/chunk-GIGFNQBO.js.map +1 -0
- package/dist/shared/chunk-GQTZPN5D.js +519 -0
- package/dist/shared/chunk-GQTZPN5D.js.map +1 -0
- package/dist/shared/chunk-H5JM2M2T.js +515 -0
- package/dist/shared/chunk-H5JM2M2T.js.map +1 -0
- package/dist/shared/chunk-HPCCD6V5.js +17 -0
- package/dist/shared/{chunk-6I3ONVU6.js.map → chunk-HPCCD6V5.js.map} +1 -1
- package/dist/shared/chunk-HTUSL2U7.js +260 -0
- package/dist/shared/chunk-HTUSL2U7.js.map +1 -0
- package/dist/shared/chunk-IQIISR22.js +794 -0
- package/dist/shared/chunk-IQIISR22.js.map +1 -0
- package/dist/shared/chunk-JK2FWFJU.js +15 -0
- package/dist/shared/{chunk-JMN3HTZU.js.map → chunk-JK2FWFJU.js.map} +1 -1
- package/dist/shared/chunk-KEM5N6GJ.js +505 -0
- package/dist/shared/chunk-KEM5N6GJ.js.map +1 -0
- package/dist/shared/chunk-KIDICX3Y.js +278 -0
- package/dist/shared/chunk-KIDICX3Y.js.map +1 -0
- package/dist/shared/chunk-KILJYJFE.js +354 -0
- package/dist/shared/chunk-KILJYJFE.js.map +1 -0
- package/dist/shared/chunk-KNREHAPN.js +13 -0
- package/dist/shared/{chunk-KSEURRVZ.js.map → chunk-KNREHAPN.js.map} +1 -1
- package/dist/shared/chunk-KT7SSWMM.js +24 -0
- package/dist/shared/{chunk-KO5FPOWZ.js.map → chunk-KT7SSWMM.js.map} +1 -1
- package/dist/shared/chunk-L6C7HUSA.js +850 -0
- package/dist/shared/chunk-L6C7HUSA.js.map +1 -0
- package/dist/shared/chunk-LCJ2VFPM.js +837 -0
- package/dist/shared/chunk-LCJ2VFPM.js.map +1 -0
- package/dist/shared/chunk-LLNPH3XR.js +148 -0
- package/dist/shared/chunk-LLNPH3XR.js.map +1 -0
- package/dist/shared/chunk-LTIJI7Y3.js +368 -0
- package/dist/shared/chunk-LTIJI7Y3.js.map +1 -0
- package/dist/shared/chunk-MFNHFN2B.js +103 -0
- package/dist/shared/{chunk-ZA3GAB4H.js.map → chunk-MFNHFN2B.js.map} +1 -1
- package/dist/shared/chunk-N3BEBLWF.js +213 -0
- package/dist/shared/chunk-N3BEBLWF.js.map +1 -0
- package/dist/shared/chunk-N3ZTQD5I.js +70 -0
- package/dist/shared/chunk-N3ZTQD5I.js.map +1 -0
- package/dist/shared/chunk-NTLAKMMQ.js +94 -0
- package/dist/shared/{chunk-ZTZJHY4E.js.map → chunk-NTLAKMMQ.js.map} +1 -1
- package/dist/shared/chunk-O5PQISX4.js +51 -0
- package/dist/shared/{chunk-VEDQV5XO.js.map → chunk-O5PQISX4.js.map} +1 -1
- package/dist/shared/chunk-OJP4HMJT.js +22 -0
- package/dist/shared/{chunk-6HLU4UI2.js.map → chunk-OJP4HMJT.js.map} +1 -1
- package/dist/shared/chunk-OSJ6KGPX.js +16 -0
- package/dist/shared/{chunk-GPEMPZXK.js.map → chunk-OSJ6KGPX.js.map} +1 -1
- package/dist/shared/chunk-OXYXZHP2.js +48 -0
- package/dist/shared/{chunk-5O4Z3YQY.js.map → chunk-OXYXZHP2.js.map} +1 -1
- package/dist/shared/chunk-Q4NPPLEU.js +34 -0
- package/dist/shared/{chunk-QWGUMKZC.js.map → chunk-Q4NPPLEU.js.map} +1 -1
- package/dist/shared/chunk-QLQVDZIL.js +11 -0
- package/dist/shared/{chunk-KLD3P5XH.js.map → chunk-QLQVDZIL.js.map} +1 -1
- package/dist/shared/chunk-RV7AYVFV.js +75 -0
- package/dist/shared/{chunk-DHI3IBOD.js.map → chunk-RV7AYVFV.js.map} +1 -1
- package/dist/shared/chunk-SE6O65HC.js +44 -0
- package/dist/shared/{chunk-NM5MMPCF.js.map → chunk-SE6O65HC.js.map} +1 -1
- package/dist/shared/chunk-TFGGYU6Y.js +394 -0
- package/dist/shared/{chunk-CZRCW5EN.js.map → chunk-TFGGYU6Y.js.map} +1 -1
- package/dist/shared/chunk-TKMWY2VN.js +18 -0
- package/dist/shared/{chunk-RDZK73KV.js.map → chunk-TKMWY2VN.js.map} +1 -1
- package/dist/shared/chunk-TNMNMYOB.js +69 -0
- package/dist/shared/{chunk-4BTB3MU2.js.map → chunk-TNMNMYOB.js.map} +1 -1
- package/dist/shared/chunk-TNTFKLCR.js +1225 -0
- package/dist/shared/chunk-TNTFKLCR.js.map +1 -0
- package/dist/shared/chunk-U5ZECCJM.js +464 -0
- package/dist/shared/chunk-U5ZECCJM.js.map +1 -0
- package/dist/shared/chunk-UXTASZ23.js +419 -0
- package/dist/shared/chunk-UXTASZ23.js.map +1 -0
- package/dist/shared/chunk-W6MRYRGJ.js +100 -0
- package/dist/shared/{chunk-CCI4C3TM.js.map → chunk-W6MRYRGJ.js.map} +1 -1
- package/dist/shared/chunk-WKN566LN.js +29 -0
- package/dist/shared/{chunk-Q4H4QEMB.js.map → chunk-WKN566LN.js.map} +1 -1
- package/dist/shared/chunk-XCWMZVF5.js +89 -0
- package/dist/shared/{chunk-ZFCUSWMT.js.map → chunk-XCWMZVF5.js.map} +1 -1
- package/dist/shared/chunk-XCZVD5H6.js +13 -0
- package/dist/shared/{chunk-HAGKVQOW.js.map → chunk-XCZVD5H6.js.map} +1 -1
- package/dist/shared/chunk-XZ6WJZHN.js +10 -0
- package/dist/shared/{chunk-DCH4ZKWT.js.map → chunk-XZ6WJZHN.js.map} +1 -1
- package/dist/shared/chunk-Y74LZNND.js +30 -0
- package/dist/shared/{chunk-GACHLACT.js.map → chunk-Y74LZNND.js.map} +1 -1
- package/dist/shared/chunk-YWOTQWIQ.js +572 -0
- package/dist/shared/chunk-YWOTQWIQ.js.map +1 -0
- package/dist/shared/chunk-ZEFOWKYP.js +44 -0
- package/dist/shared/{chunk-DQ7PRWTG.js.map → chunk-ZEFOWKYP.js.map} +1 -1
- package/dist/shared/chunk-ZGQ3AQBG.js +33 -0
- package/dist/shared/chunk-ZGQ3AQBG.js.map +1 -0
- package/dist/shared/chunk-ZLYIRH2B.js +68 -0
- package/dist/shared/{chunk-SWLUQVK7.js.map → chunk-ZLYIRH2B.js.map} +1 -1
- package/dist/shared/chunk-ZR6R6Z6O.js +496 -0
- package/dist/shared/chunk-ZR6R6Z6O.js.map +1 -0
- package/dist/shared/chunk-ZRRAK5NS.js +432 -0
- package/dist/shared/chunk-ZRRAK5NS.js.map +1 -0
- package/dist/shared/context.d.ts +1 -0
- package/dist/shared/context.d.ts.map +1 -1
- package/dist/shared/datarecords/external/airtable/handler.js +377 -1
- package/dist/shared/datarecords/external/airtable/handler.js.map +1 -1
- package/dist/shared/datarecords/external/airtable/oauth/config.js +15 -1
- package/dist/shared/datarecords/external/airtable/oauth/config.js.map +1 -1
- package/dist/shared/datarecords/external/airtable/types.js +11 -1
- package/dist/shared/datarecords/external/generic-webhook/handler.js +14 -1
- package/dist/shared/datarecords/external/generic-webhook/handler.js.map +1 -1
- package/dist/shared/datarecords/external/generic-webhook/options.js +16 -1
- package/dist/shared/datarecords/external/generic-webhook/options.js.map +1 -1
- package/dist/shared/datarecords/external/google/oauth/config.js +35 -1
- package/dist/shared/datarecords/external/google/oauth/config.js.map +1 -1
- package/dist/shared/datarecords/external/google/sheets/client.js +7 -1
- package/dist/shared/datarecords/external/google/sheets/handler.js +184 -5
- package/dist/shared/datarecords/external/google/sheets/handler.js.map +1 -1
- package/dist/shared/datarecords/external/google/sheets/types.js +7 -1
- package/dist/shared/datarecords/external/notion/handler.js +397 -1
- package/dist/shared/datarecords/external/notion/handler.js.map +1 -1
- package/dist/shared/datarecords/external/notion/oauth/config.js +11 -1
- package/dist/shared/datarecords/external/notion/oauth/config.js.map +1 -1
- package/dist/shared/datarecords/external/notion/types.js +7 -1
- package/dist/shared/datarecords/types.d.ts +6 -59
- package/dist/shared/datarecords/types.d.ts.map +1 -1
- package/dist/shared/datarecords/types.js +14 -1
- package/dist/shared/datarecords.js +9 -1
- package/dist/shared/datarecords.js.map +1 -1
- package/dist/shared/datasources/external/facebook/posts/fetcher.js +49 -1
- package/dist/shared/datasources/external/facebook/posts/fetcher.js.map +1 -1
- package/dist/shared/datasources/external/facebook/posts/schema.js +36 -1
- package/dist/shared/datasources/external/facebook/posts/schema.js.map +1 -1
- package/dist/shared/datasources/external/http-json/fetcher.js +29 -1
- package/dist/shared/datasources/external/http-json/fetcher.js.map +1 -1
- package/dist/shared/datasources/external/http-json/options.js +11 -1
- package/dist/shared/datasources/external/http-json/options.js.map +1 -1
- package/dist/shared/datasources/external/http-json/schema.js +10 -1
- package/dist/shared/datasources/external/http-json/schema.js.map +1 -1
- package/dist/shared/datasources/external/instagram/feed/fetcher.js +29 -1
- package/dist/shared/datasources/external/instagram/feed/fetcher.js.map +1 -1
- package/dist/shared/datasources/external/instagram/feed/schema.js +26 -1
- package/dist/shared/datasources/external/instagram/feed/schema.js.map +1 -1
- package/dist/shared/datasources/external/mastodon/account/fetcher.js +7 -1
- package/dist/shared/datasources/external/mastodon/account/schema.js +7 -1
- package/dist/shared/datasources/external/mastodon/options.js +10 -1
- package/dist/shared/datasources/external/mastodon/options.js.map +1 -1
- package/dist/shared/datasources/external/mastodon/status/fetcher.js +31 -1
- package/dist/shared/datasources/external/mastodon/status/fetcher.js.map +1 -1
- package/dist/shared/datasources/external/mastodon/status/sample.array.js +61 -1
- package/dist/shared/datasources/external/mastodon/status/sample.array.js.map +1 -1
- package/dist/shared/datasources/external/mastodon/status/sample.single.js +59 -1
- package/dist/shared/datasources/external/mastodon/status/sample.single.js.map +1 -1
- package/dist/shared/datasources/external/mastodon/status/schema.js +125 -1
- package/dist/shared/datasources/external/mastodon/status/schema.js.map +1 -1
- package/dist/shared/datasources/external/meta/oauth/config.js +17 -1
- package/dist/shared/datasources/external/meta/oauth/config.js.map +1 -1
- package/dist/shared/datasources/external/meta/options.js +10 -1
- package/dist/shared/datasources/external/meta/options.js.map +1 -1
- package/dist/shared/datasources/external/rss/fetcher.js +26 -1
- package/dist/shared/datasources/external/rss/fetcher.js.map +1 -1
- package/dist/shared/datasources/external/rss/options.js +10 -1
- package/dist/shared/datasources/external/rss/options.js.map +1 -1
- package/dist/shared/datasources/external/rss/schema.js +7 -1
- package/dist/shared/datasources/external/threads/media/fetcher.js +47 -1
- package/dist/shared/datasources/external/threads/media/fetcher.js.map +1 -1
- package/dist/shared/datasources/external/threads/media/schema.js +40 -1
- package/dist/shared/datasources/external/threads/media/schema.js.map +1 -1
- package/dist/shared/datasources/external/tiktok/oauth/config.js +18 -1
- package/dist/shared/datasources/external/tiktok/oauth/config.js.map +1 -1
- package/dist/shared/datasources/external/tiktok/video/fetcher.js +34 -1
- package/dist/shared/datasources/external/tiktok/video/fetcher.js.map +1 -1
- package/dist/shared/datasources/external/tiktok/video/options.js +11 -1
- package/dist/shared/datasources/external/tiktok/video/options.js.map +1 -1
- package/dist/shared/datasources/external/tiktok/video/schema.js +30 -1
- package/dist/shared/datasources/external/tiktok/video/schema.js.map +1 -1
- package/dist/shared/datasources/external/youtube/list/fetcher.js +32 -1
- package/dist/shared/datasources/external/youtube/list/fetcher.js.map +1 -1
- package/dist/shared/datasources/external/youtube/list/options.js +14 -1
- package/dist/shared/datasources/external/youtube/list/options.js.map +1 -1
- package/dist/shared/datasources/external/youtube/list/schema.js +7 -1
- package/dist/shared/datasources/external/youtube/oauth/config.js +18 -1
- package/dist/shared/datasources/external/youtube/oauth/config.js.map +1 -1
- package/dist/shared/datasources/internal/blog/schema.js +72 -1
- package/dist/shared/datasources/internal/blog/schema.js.map +1 -1
- package/dist/shared/datasources/internal/changelog/schema.js +51 -1
- package/dist/shared/datasources/internal/changelog/schema.js.map +1 -1
- package/dist/shared/datasources/internal/contact-info/schema.js +25 -1
- package/dist/shared/datasources/internal/contact-info/schema.js.map +1 -1
- package/dist/shared/datasources/internal/cv/schema.js +222 -1
- package/dist/shared/datasources/internal/cv/schema.js.map +1 -1
- package/dist/shared/datasources/internal/faq/schema.js +30 -1
- package/dist/shared/datasources/internal/faq/schema.js.map +1 -1
- package/dist/shared/datasources/internal/job-board/schema.js +224 -1
- package/dist/shared/datasources/internal/job-board/schema.js.map +1 -1
- package/dist/shared/datasources/internal/links/schema.js +7 -1
- package/dist/shared/datasources/internal/recipes/schema.js +45 -1
- package/dist/shared/datasources/internal/recipes/schema.js.map +1 -1
- package/dist/shared/datasources/internal/restaurant/schema.js +226 -1
- package/dist/shared/datasources/internal/restaurant/schema.js.map +1 -1
- package/dist/shared/datasources/samples.js +69 -1
- package/dist/shared/datasources/samples.js.map +1 -1
- package/dist/shared/datasources/schemas.js +34 -1
- package/dist/shared/datasources/schemas.js.map +1 -1
- package/dist/shared/datasources/types.d.ts +1 -1
- package/dist/shared/datasources/types.d.ts.map +1 -1
- package/dist/shared/datasources/types.js +32 -1
- package/dist/shared/datasources/utils.js +11 -1
- package/dist/shared/datasources.d.ts +1 -1
- package/dist/shared/datasources.d.ts.map +1 -1
- package/dist/shared/datasources.js +49 -1
- package/dist/shared/datasources.js.map +1 -1
- package/dist/shared/errors.js +7 -1
- package/dist/shared/images.d.ts +4 -4
- package/dist/shared/images.d.ts.map +1 -1
- package/dist/shared/images.js +44 -1
- package/dist/shared/images.js.map +1 -1
- package/dist/shared/index.js +9 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/layout-constants.js +14 -1
- package/dist/shared/layout-constants.js.map +1 -1
- package/dist/shared/manifest.js +52 -1
- package/dist/shared/manifest.js.map +1 -1
- package/dist/shared/oauth.js +8 -1
- package/dist/shared/page.d.ts +12 -126
- package/dist/shared/page.d.ts.map +1 -1
- package/dist/shared/page.js +58 -1
- package/dist/shared/prompt.js +7 -1
- package/dist/shared/responsive.js +10 -1
- package/dist/shared/responsive.js.map +1 -1
- package/dist/shared/site.d.ts +34 -31
- package/dist/shared/site.d.ts.map +1 -1
- package/dist/shared/site.js +127 -1
- package/dist/shared/site.js.map +1 -1
- package/dist/shared/sitemap.d.ts +13 -12
- package/dist/shared/sitemap.d.ts.map +1 -1
- package/dist/shared/sitemap.js +69 -1
- package/dist/shared/social-icons.js +312 -1
- package/dist/shared/social-icons.js.map +1 -1
- package/dist/shared/tests/schema-registry.test.d.ts +2 -0
- package/dist/shared/tests/schema-registry.test.d.ts.map +1 -0
- package/dist/shared/theme.d.ts +1 -1
- package/dist/shared/theme.d.ts.map +1 -1
- package/dist/shared/theme.js +35 -1
- package/dist/shared/themes/color-system.js +103 -1
- package/dist/shared/themes/color-system.js.map +1 -1
- package/dist/shared/utils/canvas-data-uri.js +7 -1
- package/dist/shared/utils/canvas-data-uri.js.map +1 -1
- package/dist/shared/utils/invariant.js +7 -1
- package/dist/shared/utils/json-date.js +7 -1
- package/dist/shared/utils/llm.d.ts +2 -3
- package/dist/shared/utils/llm.d.ts.map +1 -1
- package/dist/shared/utils/llm.js +24 -1
- package/dist/shared/utils/merge.js +7 -1
- package/dist/shared/utils/object-hash.js +13 -1
- package/dist/shared/utils/object-hash.js.map +1 -1
- package/dist/shared/utils/schema-registry.d.ts +5 -0
- package/dist/shared/utils/schema-registry.d.ts.map +1 -0
- package/dist/shared/utils/schema-registry.js +29 -0
- package/dist/shared/utils/schema-registry.js.map +1 -0
- package/dist/shared/utils/schema.d.ts +2 -1
- package/dist/shared/utils/schema.d.ts.map +1 -1
- package/dist/shared/utils/schema.js +31 -1
- package/dist/shared/utils/string-enum.js +7 -1
- package/dist/shared/utils/tests/schema-registry.test.d.ts +2 -0
- package/dist/shared/utils/tests/schema-registry.test.d.ts.map +1 -0
- package/dist/shared/utils/try-catch.js +13 -1
- package/dist/shared/utils/try-catch.js.map +1 -1
- package/dist/shared/utils/typed-ref.js +7 -1
- package/package.json +9 -10
- package/src/shared/ai/schemas.ts +44 -12
- package/src/shared/ai/types.ts +135 -59
- package/src/shared/attributes.ts +37 -27
- package/src/shared/bricks/manifests/_types.ts +9 -0
- package/src/shared/bricks/manifests/accordion.manifest.ts +128 -161
- package/src/shared/bricks/manifests/all-manifests.ts +16 -0
- package/src/shared/bricks/manifests/box.manifest.ts +195 -129
- package/src/shared/bricks/manifests/button.manifest.ts +158 -71
- package/src/shared/bricks/manifests/card.manifest.ts +200 -28
- package/src/shared/bricks/manifests/carousel.manifest.ts +154 -22
- package/src/shared/bricks/manifests/footer.manifest.ts +38 -32
- package/src/shared/bricks/manifests/form.manifest.ts +122 -7
- package/src/shared/bricks/manifests/hero.manifest.ts +103 -18
- package/src/shared/bricks/manifests/html.manifest.ts +2 -5
- package/src/shared/bricks/manifests/icon.manifest.ts +216 -36
- package/src/shared/bricks/manifests/image.manifest.ts +103 -2
- package/src/shared/bricks/manifests/images-gallery.manifest.ts +2 -5
- package/src/shared/bricks/manifests/map.manifest.ts +2 -5
- package/src/shared/bricks/manifests/navbar.manifest.ts +3 -8
- package/src/shared/bricks/manifests/sidebar.manifest.ts +2 -5
- package/src/shared/bricks/manifests/social-links.manifest.ts +2 -5
- package/src/shared/bricks/manifests/spacer.manifest.ts +2 -5
- package/src/shared/bricks/manifests/table.manifest.ts +440 -0
- package/src/shared/bricks/manifests/tabs.manifest.ts +573 -0
- package/src/shared/bricks/manifests/testimonials.manifest.ts +2 -5
- package/src/shared/bricks/manifests/text.manifest.ts +31 -10
- package/src/shared/bricks/manifests/timeline.manifest.ts +438 -0
- package/src/shared/bricks/manifests/video.manifest.ts +2 -5
- package/src/shared/bricks/props/color-preset.ts +3 -1
- package/src/shared/bricks/props/dynamic.ts +0 -1
- package/src/shared/bricks/props/string.ts +1 -1
- package/src/shared/bricks.ts +61 -49
- package/src/shared/context.ts +1 -0
- package/src/shared/datarecords/types.ts +47 -37
- package/src/shared/datasources/types.ts +1 -5
- package/src/shared/datasources.ts +2 -4
- package/src/shared/images.ts +10 -8
- package/src/shared/page.ts +0 -5
- package/src/shared/site.ts +3 -3
- package/src/shared/sitemap.ts +14 -16
- package/src/shared/tests/schema-registry.test.ts +12 -0
- package/src/shared/theme.ts +1 -4
- package/src/shared/utils/llm.ts +13 -12
- package/src/shared/utils/schema-registry.ts +82 -0
- package/src/shared/utils/schema.ts +18 -3
- package/src/shared/utils/tests/schema-registry.test.ts +13 -0
- package/src/shared/utils/tests/schema.test.ts +124 -56
- package/dist/shared/bricks/props/enum.d.ts +0 -13
- package/dist/shared/bricks/props/enum.d.ts.map +0 -1
- package/dist/shared/chunk-3YVJ2ELD.js +0 -4
- package/dist/shared/chunk-4BTB3MU2.js +0 -4
- package/dist/shared/chunk-4WDWJA3N.js +0 -4
- package/dist/shared/chunk-5O4Z3YQY.js +0 -4
- package/dist/shared/chunk-5YRC3IT3.js +0 -4
- package/dist/shared/chunk-6HLU4UI2.js +0 -4
- package/dist/shared/chunk-6I3ONVU6.js +0 -4
- package/dist/shared/chunk-7A2JNQX3.js +0 -4
- package/dist/shared/chunk-7A2JNQX3.js.map +0 -1
- package/dist/shared/chunk-A3GF4PYW.js +0 -4
- package/dist/shared/chunk-A3GF4PYW.js.map +0 -1
- package/dist/shared/chunk-A3K4NUVP.js +0 -4
- package/dist/shared/chunk-A3K4NUVP.js.map +0 -1
- package/dist/shared/chunk-AFVJZPLS.js +0 -4
- package/dist/shared/chunk-AFVJZPLS.js.map +0 -1
- package/dist/shared/chunk-AI4GHU7R.js +0 -4
- package/dist/shared/chunk-AI4GHU7R.js.map +0 -1
- package/dist/shared/chunk-B3EATRFX.js +0 -4
- package/dist/shared/chunk-B3EATRFX.js.map +0 -1
- package/dist/shared/chunk-CCI4C3TM.js +0 -4
- package/dist/shared/chunk-CFF6Q7O7.js +0 -7
- package/dist/shared/chunk-CFF6Q7O7.js.map +0 -1
- package/dist/shared/chunk-CZRCW5EN.js +0 -4
- package/dist/shared/chunk-DCH4ZKWT.js +0 -4
- package/dist/shared/chunk-DHI3IBOD.js +0 -4
- package/dist/shared/chunk-DQ7PRWTG.js +0 -4
- package/dist/shared/chunk-E6XEI7IK.js +0 -4
- package/dist/shared/chunk-E6XEI7IK.js.map +0 -1
- package/dist/shared/chunk-FLOMNC6J.js +0 -4
- package/dist/shared/chunk-FLOMNC6J.js.map +0 -1
- package/dist/shared/chunk-G5CJU6RD.js +0 -7
- package/dist/shared/chunk-G5CJU6RD.js.map +0 -1
- package/dist/shared/chunk-GACHLACT.js +0 -4
- package/dist/shared/chunk-GLS7HPIZ.js +0 -4
- package/dist/shared/chunk-GOMXZC4B.js +0 -35
- package/dist/shared/chunk-GOMXZC4B.js.map +0 -1
- package/dist/shared/chunk-GPEMPZXK.js +0 -4
- package/dist/shared/chunk-HAGKVQOW.js +0 -4
- package/dist/shared/chunk-I3VL6SRH.js +0 -9
- package/dist/shared/chunk-I3VL6SRH.js.map +0 -1
- package/dist/shared/chunk-IKC3FK7L.js +0 -4
- package/dist/shared/chunk-IKC3FK7L.js.map +0 -1
- package/dist/shared/chunk-IKHZD2JH.js +0 -4
- package/dist/shared/chunk-IKHZD2JH.js.map +0 -1
- package/dist/shared/chunk-IUXCWWGO.js +0 -4
- package/dist/shared/chunk-JMN3HTZU.js +0 -4
- package/dist/shared/chunk-KBHDY425.js +0 -4
- package/dist/shared/chunk-KFM6KXSE.js +0 -4
- package/dist/shared/chunk-KLD3P5XH.js +0 -4
- package/dist/shared/chunk-KO5FPOWZ.js +0 -4
- package/dist/shared/chunk-KSEURRVZ.js +0 -4
- package/dist/shared/chunk-KYY3PHP7.js +0 -4
- package/dist/shared/chunk-NJGXC7D6.js +0 -4
- package/dist/shared/chunk-NJGXC7D6.js.map +0 -1
- package/dist/shared/chunk-NM5MMPCF.js +0 -4
- package/dist/shared/chunk-OGBMYMZD.js +0 -4
- package/dist/shared/chunk-OGBMYMZD.js.map +0 -1
- package/dist/shared/chunk-OHNYCXPX.js +0 -4
- package/dist/shared/chunk-OIY3EPHO.js +0 -4
- package/dist/shared/chunk-PIG623TZ.js +0 -4
- package/dist/shared/chunk-PIG623TZ.js.map +0 -1
- package/dist/shared/chunk-PLSV746R.js +0 -4
- package/dist/shared/chunk-PLSV746R.js.map +0 -1
- package/dist/shared/chunk-PSCN3VVA.js +0 -4
- package/dist/shared/chunk-PSCN3VVA.js.map +0 -1
- package/dist/shared/chunk-PSTFJ5IJ.js +0 -4
- package/dist/shared/chunk-PSTFJ5IJ.js.map +0 -1
- package/dist/shared/chunk-PXI7AHWS.js +0 -4
- package/dist/shared/chunk-PXI7AHWS.js.map +0 -1
- package/dist/shared/chunk-Q4H4QEMB.js +0 -4
- package/dist/shared/chunk-QGYZ7CG5.js +0 -4
- package/dist/shared/chunk-QGYZ7CG5.js.map +0 -1
- package/dist/shared/chunk-QWGUMKZC.js +0 -4
- package/dist/shared/chunk-QX6OGRRT.js +0 -5
- package/dist/shared/chunk-QX6OGRRT.js.map +0 -1
- package/dist/shared/chunk-R6ATC4TC.js +0 -4
- package/dist/shared/chunk-R6ATC4TC.js.map +0 -1
- package/dist/shared/chunk-RDZK73KV.js +0 -4
- package/dist/shared/chunk-RJYZ5FAR.js +0 -4
- package/dist/shared/chunk-SQ5T4AT5.js +0 -6
- package/dist/shared/chunk-SQ5T4AT5.js.map +0 -1
- package/dist/shared/chunk-SWLUQVK7.js +0 -4
- package/dist/shared/chunk-SXHDQ64Z.js +0 -5
- package/dist/shared/chunk-SXHDQ64Z.js.map +0 -1
- package/dist/shared/chunk-SY6DZLTC.js +0 -4
- package/dist/shared/chunk-SY6DZLTC.js.map +0 -1
- package/dist/shared/chunk-VEDQV5XO.js +0 -4
- package/dist/shared/chunk-W33JMRRN.js +0 -4
- package/dist/shared/chunk-WBZW5LVH.js +0 -4
- package/dist/shared/chunk-WBZW5LVH.js.map +0 -1
- package/dist/shared/chunk-WHTPGWUV.js +0 -4
- package/dist/shared/chunk-WYVJE6J5.js +0 -4
- package/dist/shared/chunk-WYVJE6J5.js.map +0 -1
- package/dist/shared/chunk-ZA3GAB4H.js +0 -9
- package/dist/shared/chunk-ZFCUSWMT.js +0 -4
- package/dist/shared/chunk-ZQPXQCY2.js +0 -4
- package/dist/shared/chunk-ZQPXQCY2.js.map +0 -1
- package/dist/shared/chunk-ZTZJHY4E.js +0 -4
- package/src/shared/bricks/props/enum.ts +0 -38
- /package/dist/shared/bricks/{props/enum.js.map → manifests/_types.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/datarecords/external/notion/handler.ts"],"sourcesContent":["import {\n Client,\n type CreateDatabaseResponse,\n type DatabaseObjectResponse,\n type GetPageResponse,\n type PageObjectResponse,\n} from \"@notionhq/client\";\nimport type { TObject, TProperties } from \"@sinclair/typebox\";\nimport { nanoid } from \"nanoid\";\nimport type { ListPagesResponse, NotionOptions, NotionPage, NotionPages } from \"./types\";\n\nconst MAX_CALL = 10;\nconst MAX_PAGES = 1000;\n\nexport type { CreateDatabaseResponse, DatabaseObjectResponse, ListPagesResponse };\n\nexport async function saveRecord({\n formData,\n options,\n properties,\n accessToken,\n}: {\n formData: FormData;\n options: NotionOptions;\n properties: TProperties;\n accessToken: string;\n}) {\n const client = new Client({\n auth: accessToken,\n });\n const notionData = buildCreatePageParameters(formData, options.properties);\n\n try {\n return client.pages.create({\n parent: { database_id: options.id },\n properties: {\n ...notionData,\n },\n });\n } catch (e) {\n return;\n }\n}\n\nasync function searchPages(\n client: Client,\n pages: NotionPages,\n parameters: {\n maxResults?: number;\n maxCalls?: number;\n },\n offset?: string,\n resultIndex?: number,\n): Promise<ListPagesResponse> {\n const nextIndex = resultIndex ? resultIndex + 1 : 1;\n // Notion API has a hard limit of 300 results (3 requests of 100 results)\n if (nextIndex > (parameters?.maxCalls ?? MAX_CALL)) {\n return {\n status: \"max_call_reached\",\n pages,\n };\n }\n try {\n const response = await client.search({\n filter: {\n property: \"object\",\n value: \"page\",\n },\n start_cursor: offset,\n page_size: 100, // default\n });\n if (!response) {\n return {\n status: \"error\",\n pages,\n };\n }\n for (const d in response.results) {\n const p = response.results[d] as PageObjectResponse;\n\n if (p.parent.type !== \"database_id\") {\n const page = {\n id: p.id,\n name:\n p.properties.title &&\n p.properties.title.type === \"title\" &&\n Array.isArray(p.properties.title.title) &&\n p.properties.title.title[0]?.plain_text\n ? p.properties.title.title[0].plain_text\n : \"No Title\",\n };\n pages.push(page);\n if (pages.length >= (parameters?.maxResults ?? MAX_PAGES)) {\n return {\n status: \"max_pages_reached\",\n pages: pages,\n };\n }\n }\n }\n if (response.has_more && response.next_cursor) {\n const moreResults = await searchPages(client, pages, parameters, response.next_cursor, nextIndex);\n if (moreResults.status !== \"success\") {\n return {\n status: moreResults.status,\n pages: pages,\n };\n }\n return moreResults;\n }\n } catch (error) {\n console.error(\"Error searching Notion pages:\", error);\n }\n return {\n status: \"success\",\n pages,\n };\n}\n\nexport async function listPages(\n accessToken: string,\n parameters?: {\n maxResults?: number;\n maxCalls?: number;\n },\n): Promise<ListPagesResponse> {\n try {\n const client = new Client({\n auth: accessToken,\n });\n\n const response = await searchPages(client, [], { ...parameters });\n return response;\n } catch (error) {\n console.error(\"Error listing Notion databases:\", error);\n throw error;\n }\n}\n\n/**\n * In Notion, databases column are sorted by alphabetical order\n * @param schema\n * @returns\n */\nfunction buildDatabaseProperties(schemaProperties: TProperties, requiredFields: string[] = []) {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n const properties: Record<string, any> = {};\n\n for (const [fieldName, field] of Object.entries(schemaProperties)) {\n if (field.type === \"string\") {\n if (fieldName in (requiredFields ?? []) && fieldName === \"id\") {\n properties[fieldName] = {\n title: {},\n name: fieldName,\n type: \"title\",\n };\n } else {\n if (field.format === \"email\") {\n properties[fieldName] = {\n type: \"email\",\n name: fieldName,\n email: {},\n };\n } else if (field.format === \"uri\") {\n properties[fieldName] = {\n type: \"url\",\n name: fieldName,\n url: {},\n };\n } else if (field.format === \"date\" || field.format === \"date-time\") {\n properties[fieldName] = {\n type: \"date\",\n name: fieldName,\n date: {},\n };\n } else {\n if (field.enum && Array.isArray(field.enum) && field.enum.length > 0) {\n if (field.metadata?.[\"ui:widget\"] === \"checkbox\") {\n properties[fieldName] = {\n type: \"multi_select\",\n name: fieldName,\n multi_select: {\n options: field.enum.map((option) => ({\n name: option,\n })),\n },\n };\n } else {\n properties[fieldName] = {\n type: \"select\",\n name: fieldName,\n select: {\n options: field.enum.map((option) => ({\n name: option,\n })),\n },\n };\n }\n } else {\n properties[fieldName] = {\n rich_text: {},\n name: fieldName,\n type: \"rich_text\",\n };\n }\n }\n }\n } else if (field.type === \"number\") {\n properties[fieldName] = {\n number: {},\n };\n } else if (field.type === \"boolean\") {\n properties[fieldName] = {\n checkbox: {},\n };\n }\n }\n\n // if no id field of type title, add one\n if (!properties.id) {\n properties.id = {\n title: {},\n name: \"id\",\n type: \"title\",\n };\n }\n return properties;\n}\n\nexport async function updateTable({\n id,\n newName,\n newProperties,\n accessToken,\n}: {\n id: string;\n newName?: string;\n newProperties?: TProperties;\n accessToken: string;\n}): Promise<NotionOptions> {\n const client = new Client({\n auth: accessToken,\n });\n\n const properties = newProperties ? buildDatabaseProperties(newProperties) : {};\n const response = (await client.databases.update({\n database_id: id,\n ...(newName\n ? {\n title: [\n {\n type: \"text\" as const,\n text: {\n content: newName,\n },\n },\n ],\n }\n : {}),\n ...(Object.keys(properties).length > 0 ? { properties } : {}),\n })) as DatabaseObjectResponse;\n if (!response) {\n throw new Error(\"Failed to update Notion database\");\n }\n return {\n id: response.id,\n name: response.title[0]?.plain_text,\n properties: response.properties,\n url: response.url,\n };\n}\n\nexport async function createTable({\n name,\n schema,\n pageId,\n accessToken,\n}: {\n name: string;\n schema: TObject;\n pageId: string;\n accessToken: string;\n}): Promise<NotionOptions> {\n const properties = buildDatabaseProperties(schema.properties, schema.required);\n const data = {\n parent: { type: \"page_id\" as const, page_id: pageId },\n title: [\n {\n type: \"text\" as const,\n text: {\n content: name,\n },\n },\n ],\n properties,\n };\n const client = new Client({\n auth: accessToken,\n });\n const response = (await client.databases.create(data)) as CreateDatabaseResponse;\n if (!response) {\n throw new Error(\"Failed to create Notion database\");\n }\n const table = (await client.databases.retrieve({ database_id: response.id })) as DatabaseObjectResponse;\n if (!table) {\n throw new Error(\"Failed to retrieve Notion database after creation\");\n }\n return {\n id: table.id,\n name: table.title[0]?.plain_text,\n properties: table.properties,\n url: table.url,\n };\n}\n\nexport async function checkPage({\n pageId,\n accessToken,\n}: {\n pageId: string;\n accessToken: string;\n}): Promise<NotionPage | undefined> {\n const client = new Client({\n auth: accessToken,\n });\n try {\n const response = (await client.pages.retrieve({ page_id: pageId })) as GetPageResponse;\n if (!response) {\n console.log(\"Failed to retrieve Notion page\");\n return;\n }\n if (response) {\n // Convert the complex Notion response to a simple type\n const page = response as PageObjectResponse;\n return {\n id: page.id,\n name:\n page.properties.title &&\n page.properties.title.type === \"title\" &&\n Array.isArray(page.properties.title.title) &&\n page.properties.title.title[0]?.plain_text\n ? page.properties.title.title[0].plain_text\n : \"No Title\",\n };\n }\n } catch (e) {\n console.error(\"Error retrieving Notion page:\", e);\n }\n return;\n}\n\nfunction buildCreatePageParameters(data: FormData, databaseProperties: NotionOptions[\"properties\"]) {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n const notionData: Record<string, any> = {};\n for (const [key, value] of data.entries()) {\n if (value === null || value === undefined || value === \"\") continue;\n if (key in databaseProperties) {\n switch (databaseProperties[key].type) {\n case \"title\":\n notionData[key] = {\n title: [\n {\n text: {\n content: String(value),\n },\n },\n ],\n };\n break;\n case \"rich_text\":\n notionData[key] = {\n rich_text: [\n {\n text: {\n content: String(value),\n },\n },\n ],\n };\n break;\n case \"email\":\n notionData[key] = {\n email: String(value),\n };\n break;\n case \"phone_number\":\n notionData[key] = {\n phone_number: String(value),\n };\n break;\n case \"url\":\n notionData[key] = {\n url: String(value),\n };\n break;\n case \"number\":\n notionData[key] = {\n number: Number(value),\n };\n break;\n case \"checkbox\":\n notionData[key] = {\n checkbox: value === \"true\" || value === \"1\",\n };\n break;\n case \"date\":\n notionData[key] = {\n date: value ? { start: String(value) } : null,\n };\n break;\n case \"select\":\n notionData[key] = {\n select: {\n name: String(value),\n },\n };\n break;\n case \"multi_select\": {\n const getValues = (value: string) => {\n if (value.startsWith(\"[\") && value.endsWith(\"]\")) {\n try {\n return JSON.parse(value);\n } catch {\n return [value];\n }\n }\n if (value.includes(\",\")) {\n return value\n .split(\",\")\n .map((v) => v.trim())\n .filter((v) => v.length > 0);\n }\n return [value];\n };\n const values = getValues(String(value));\n notionData[key] = {\n multi_select: values.map((v: string) => ({\n name: v,\n })),\n };\n break;\n }\n default:\n console.warn(`Unsupported property type for key \"${key}\": ${databaseProperties[key].type}`);\n notionData[key] = {\n rich_text: [\n {\n text: {\n content: String(value),\n },\n },\n ],\n };\n }\n }\n }\n if (!(\"id\" in notionData)) {\n notionData.id = {\n title: [\n {\n text: {\n content: nanoid(5),\n },\n },\n ],\n };\n }\n return notionData;\n}\n"],"mappings":";;AAAA,OACE,UAAAA,MAKK,mBAEP,OAAS,UAAAC,MAAc,SAGvB,IAAMC,EAAW,GACXC,EAAY,IAIlB,eAAsBC,EAAW,CAC/B,S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,CAAK,CAAC,EACtClC,EAAWiC,CAAG,EAAI,CAChB,aAAcE,EAAO,IAAKC,IAAe,CACvC,KAAMA,CACR,EAAE,CACJ,EACA,KACF,CACA,QACE,QAAQ,KAAK,sCAAsCH,CAAG,MAAMD,EAAmBC,CAAG,EAAE,IAAI,EAAE,EAC1FjC,EAAWiC,CAAG,EAAI,CAChB,UAAW,CACT,CACE,KAAM,CACJ,QAAS,OAAOC,CAAK,CACvB,CACF,CACF,CACF,CACJ,CAGJ,MAAM,OAAQlC,IACZA,EAAW,GAAK,CACd,MAAO,CACL,CACE,KAAM,CACJ,QAAST,EAAO,CAAC,CACnB,CACF,CACF,CACF,GAEKS,CACT","names":["Client","nanoid","MAX_CALL","MAX_PAGES","saveRecord","formData","options","properties","accessToken","client","notionData","buildCreatePageParameters","searchPages","pages","parameters","offset","resultIndex","nextIndex","response","d","p","page","moreResults","error","listPages","buildDatabaseProperties","schemaProperties","requiredFields","fieldName","field","option","updateTable","id","newName","newProperties","createTable","name","schema","pageId","data","table","checkPage","databaseProperties","key","value","values","v"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/datarecords/external/notion/handler.ts"],"sourcesContent":["import {\n Client,\n type CreateDatabaseResponse,\n type DatabaseObjectResponse,\n type GetPageResponse,\n type PageObjectResponse,\n} from \"@notionhq/client\";\nimport type { TObject, TProperties } from \"@sinclair/typebox\";\nimport { nanoid } from \"nanoid\";\nimport type { ListPagesResponse, NotionOptions, NotionPage, NotionPages } from \"./types\";\n\nconst MAX_CALL = 10;\nconst MAX_PAGES = 1000;\n\nexport type { CreateDatabaseResponse, DatabaseObjectResponse, ListPagesResponse };\n\nexport async function saveRecord({\n formData,\n options,\n properties,\n accessToken,\n}: {\n formData: FormData;\n options: NotionOptions;\n properties: TProperties;\n accessToken: string;\n}) {\n const client = new Client({\n auth: accessToken,\n });\n const notionData = buildCreatePageParameters(formData, options.properties);\n\n try {\n return client.pages.create({\n parent: { database_id: options.id },\n properties: {\n ...notionData,\n },\n });\n } catch (e) {\n return;\n }\n}\n\nasync function searchPages(\n client: Client,\n pages: NotionPages,\n parameters: {\n maxResults?: number;\n maxCalls?: number;\n },\n offset?: string,\n resultIndex?: number,\n): Promise<ListPagesResponse> {\n const nextIndex = resultIndex ? resultIndex + 1 : 1;\n // Notion API has a hard limit of 300 results (3 requests of 100 results)\n if (nextIndex > (parameters?.maxCalls ?? MAX_CALL)) {\n return {\n status: \"max_call_reached\",\n pages,\n };\n }\n try {\n const response = await client.search({\n filter: {\n property: \"object\",\n value: \"page\",\n },\n start_cursor: offset,\n page_size: 100, // default\n });\n if (!response) {\n return {\n status: \"error\",\n pages,\n };\n }\n for (const d in response.results) {\n const p = response.results[d] as PageObjectResponse;\n\n if (p.parent.type !== \"database_id\") {\n const page = {\n id: p.id,\n name:\n p.properties.title &&\n p.properties.title.type === \"title\" &&\n Array.isArray(p.properties.title.title) &&\n p.properties.title.title[0]?.plain_text\n ? p.properties.title.title[0].plain_text\n : \"No Title\",\n };\n pages.push(page);\n if (pages.length >= (parameters?.maxResults ?? MAX_PAGES)) {\n return {\n status: \"max_pages_reached\",\n pages: pages,\n };\n }\n }\n }\n if (response.has_more && response.next_cursor) {\n const moreResults = await searchPages(client, pages, parameters, response.next_cursor, nextIndex);\n if (moreResults.status !== \"success\") {\n return {\n status: moreResults.status,\n pages: pages,\n };\n }\n return moreResults;\n }\n } catch (error) {\n console.error(\"Error searching Notion pages:\", error);\n }\n return {\n status: \"success\",\n pages,\n };\n}\n\nexport async function listPages(\n accessToken: string,\n parameters?: {\n maxResults?: number;\n maxCalls?: number;\n },\n): Promise<ListPagesResponse> {\n try {\n const client = new Client({\n auth: accessToken,\n });\n\n const response = await searchPages(client, [], { ...parameters });\n return response;\n } catch (error) {\n console.error(\"Error listing Notion databases:\", error);\n throw error;\n }\n}\n\n/**\n * In Notion, databases column are sorted by alphabetical order\n * @param schema\n * @returns\n */\nfunction buildDatabaseProperties(schemaProperties: TProperties, requiredFields: string[] = []) {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n const properties: Record<string, any> = {};\n\n for (const [fieldName, field] of Object.entries(schemaProperties)) {\n if (field.type === \"string\") {\n if (fieldName in (requiredFields ?? []) && fieldName === \"id\") {\n properties[fieldName] = {\n title: {},\n name: fieldName,\n type: \"title\",\n };\n } else {\n if (field.format === \"email\") {\n properties[fieldName] = {\n type: \"email\",\n name: fieldName,\n email: {},\n };\n } else if (field.format === \"uri\") {\n properties[fieldName] = {\n type: \"url\",\n name: fieldName,\n url: {},\n };\n } else if (field.format === \"date\" || field.format === \"date-time\") {\n properties[fieldName] = {\n type: \"date\",\n name: fieldName,\n date: {},\n };\n } else {\n if (field.enum && Array.isArray(field.enum) && field.enum.length > 0) {\n if (field.metadata?.[\"ui:widget\"] === \"checkbox\") {\n properties[fieldName] = {\n type: \"multi_select\",\n name: fieldName,\n multi_select: {\n options: field.enum.map((option) => ({\n name: option,\n })),\n },\n };\n } else {\n properties[fieldName] = {\n type: \"select\",\n name: fieldName,\n select: {\n options: field.enum.map((option) => ({\n name: option,\n })),\n },\n };\n }\n } else {\n properties[fieldName] = {\n rich_text: {},\n name: fieldName,\n type: \"rich_text\",\n };\n }\n }\n }\n } else if (field.type === \"number\") {\n properties[fieldName] = {\n number: {},\n };\n } else if (field.type === \"boolean\") {\n properties[fieldName] = {\n checkbox: {},\n };\n }\n }\n\n // if no id field of type title, add one\n if (!properties.id) {\n properties.id = {\n title: {},\n name: \"id\",\n type: \"title\",\n };\n }\n return properties;\n}\n\nexport async function updateTable({\n id,\n newName,\n newProperties,\n accessToken,\n}: {\n id: string;\n newName?: string;\n newProperties?: TProperties;\n accessToken: string;\n}): Promise<NotionOptions> {\n const client = new Client({\n auth: accessToken,\n });\n\n const properties = newProperties ? buildDatabaseProperties(newProperties) : {};\n const response = (await client.databases.update({\n database_id: id,\n ...(newName\n ? {\n title: [\n {\n type: \"text\" as const,\n text: {\n content: newName,\n },\n },\n ],\n }\n : {}),\n ...(Object.keys(properties).length > 0 ? { properties } : {}),\n })) as DatabaseObjectResponse;\n if (!response) {\n throw new Error(\"Failed to update Notion database\");\n }\n return {\n id: response.id,\n name: response.title[0]?.plain_text,\n properties: response.properties,\n url: response.url,\n };\n}\n\nexport async function createTable({\n name,\n schema,\n pageId,\n accessToken,\n}: {\n name: string;\n schema: TObject;\n pageId: string;\n accessToken: string;\n}): Promise<NotionOptions> {\n const properties = buildDatabaseProperties(schema.properties, schema.required);\n const data = {\n parent: { type: \"page_id\" as const, page_id: pageId },\n title: [\n {\n type: \"text\" as const,\n text: {\n content: name,\n },\n },\n ],\n properties,\n };\n const client = new Client({\n auth: accessToken,\n });\n const response = (await client.databases.create(data)) as CreateDatabaseResponse;\n if (!response) {\n throw new Error(\"Failed to create Notion database\");\n }\n const table = (await client.databases.retrieve({ database_id: response.id })) as DatabaseObjectResponse;\n if (!table) {\n throw new Error(\"Failed to retrieve Notion database after creation\");\n }\n return {\n id: table.id,\n name: table.title[0]?.plain_text,\n properties: table.properties,\n url: table.url,\n };\n}\n\nexport async function checkPage({\n pageId,\n accessToken,\n}: {\n pageId: string;\n accessToken: string;\n}): Promise<NotionPage | undefined> {\n const client = new Client({\n auth: accessToken,\n });\n try {\n const response = (await client.pages.retrieve({ page_id: pageId })) as GetPageResponse;\n if (!response) {\n console.log(\"Failed to retrieve Notion page\");\n return;\n }\n if (response) {\n // Convert the complex Notion response to a simple type\n const page = response as PageObjectResponse;\n return {\n id: page.id,\n name:\n page.properties.title &&\n page.properties.title.type === \"title\" &&\n Array.isArray(page.properties.title.title) &&\n page.properties.title.title[0]?.plain_text\n ? page.properties.title.title[0].plain_text\n : \"No Title\",\n };\n }\n } catch (e) {\n console.error(\"Error retrieving Notion page:\", e);\n }\n return;\n}\n\nfunction buildCreatePageParameters(data: FormData, databaseProperties: NotionOptions[\"properties\"]) {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n const notionData: Record<string, any> = {};\n for (const [key, value] of data.entries()) {\n if (value === null || value === undefined || value === \"\") continue;\n if (key in databaseProperties) {\n switch (databaseProperties[key].type) {\n case \"title\":\n notionData[key] = {\n title: [\n {\n text: {\n content: String(value),\n },\n },\n ],\n };\n break;\n case \"rich_text\":\n notionData[key] = {\n rich_text: [\n {\n text: {\n content: String(value),\n },\n },\n ],\n };\n break;\n case \"email\":\n notionData[key] = {\n email: String(value),\n };\n break;\n case \"phone_number\":\n notionData[key] = {\n phone_number: String(value),\n };\n break;\n case \"url\":\n notionData[key] = {\n url: String(value),\n };\n break;\n case \"number\":\n notionData[key] = {\n number: Number(value),\n };\n break;\n case \"checkbox\":\n notionData[key] = {\n checkbox: value === \"true\" || value === \"1\",\n };\n break;\n case \"date\":\n notionData[key] = {\n date: value ? { start: String(value) } : null,\n };\n break;\n case \"select\":\n notionData[key] = {\n select: {\n name: String(value),\n },\n };\n break;\n case \"multi_select\": {\n const getValues = (value: string) => {\n if (value.startsWith(\"[\") && value.endsWith(\"]\")) {\n try {\n return JSON.parse(value);\n } catch {\n return [value];\n }\n }\n if (value.includes(\",\")) {\n return value\n .split(\",\")\n .map((v) => v.trim())\n .filter((v) => v.length > 0);\n }\n return [value];\n };\n const values = getValues(String(value));\n notionData[key] = {\n multi_select: values.map((v: string) => ({\n name: v,\n })),\n };\n break;\n }\n default:\n console.warn(`Unsupported property type for key \"${key}\": ${databaseProperties[key].type}`);\n notionData[key] = {\n rich_text: [\n {\n text: {\n content: String(value),\n },\n },\n ],\n };\n }\n }\n }\n if (!(\"id\" in notionData)) {\n notionData.id = {\n title: [\n {\n text: {\n content: nanoid(5),\n },\n },\n ],\n };\n }\n return notionData;\n}\n"],"mappings":";;;;;AAAA;AAAA,EACE;AAAA,OAKK;AAEP,SAAS,cAAc;AAGvB,IAAM,WAAW;AACjB,IAAM,YAAY;AAIlB,eAAsB,WAAW;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,SAAS,IAAI,OAAO;AAAA,IACxB,MAAM;AAAA,EACR,CAAC;AACD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AAM,SAAS,UAAU,OAAO,KAAK,CAAC;AACtC,qBAAW,GAAG,IAAI;AAAA,YAChB,cAAc,OAAO,IAAI,CAAC,OAAe;AAAA,cACvC,MAAM;AAAA,YACR,EAAE;AAAA,UACJ;AACA;AAAA,QACF;AAAA,QACA;AACE,kBAAQ,KAAK,sCAAsC,GAAG,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE;AAC1F,qBAAW,GAAG,IAAI;AAAA,YAChB,WAAW;AAAA,cACT;AAAA,gBACE,MAAM;AAAA,kBACJ,SAAS,OAAO,KAAK;AAAA,gBACvB;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACA,MAAI,EAAE,QAAQ,aAAa;AACzB,eAAW,KAAK;AAAA,MACd,OAAO;AAAA,QACL;AAAA,UACE,MAAM;AAAA,YACJ,SAAS,OAAO,CAAC;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":["value"]}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import "../../../../chunk-ZGQ3AQBG.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/datarecords/external/notion/oauth/config.ts
|
|
6
|
+
import { Type } from "@sinclair/typebox";
|
|
7
|
+
var notionOAuthTokenSchema = Type.Object({
|
|
8
|
+
access_token: Type.String(),
|
|
9
|
+
refresh_token: Type.String()
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
notionOAuthTokenSchema
|
|
13
|
+
};
|
|
4
14
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/shared/datarecords/external/notion/oauth/config.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const notionOAuthTokenSchema = Type.Object({\n access_token: Type.String(),\n refresh_token: Type.String(),\n});\nexport type NotionOAuthToken = Static<typeof notionOAuthTokenSchema>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/shared/datarecords/external/notion/oauth/config.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const notionOAuthTokenSchema = Type.Object({\n access_token: Type.String(),\n refresh_token: Type.String(),\n});\nexport type NotionOAuthToken = Static<typeof notionOAuthTokenSchema>;\n"],"mappings":";;;;;AAAA,SAAS,YAAyB;AAE3B,IAAM,yBAAyB,KAAK,OAAO;AAAA,EAChD,cAAc,KAAK,OAAO;AAAA,EAC1B,eAAe,KAAK,OAAO;AAC7B,CAAC;","names":[]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import{
|
|
3
|
+
import {
|
|
4
|
+
notionOptions
|
|
5
|
+
} from "../../../chunk-7LAWWRU7.js";
|
|
6
|
+
import "../../../chunk-ZGQ3AQBG.js";
|
|
7
|
+
export {
|
|
8
|
+
notionOptions
|
|
9
|
+
};
|
|
4
10
|
//# sourceMappingURL=types.js.map
|
|
@@ -1,76 +1,23 @@
|
|
|
1
1
|
import { type Static } from "@sinclair/typebox";
|
|
2
2
|
export declare const connectorSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"airtable">, import("@sinclair/typebox").TLiteral<"google-sheets">, import("@sinclair/typebox").TLiteral<"notion">, import("@sinclair/typebox").TLiteral<"internal">]>;
|
|
3
3
|
export type DatarecordConnector = Static<typeof connectorSchema>;
|
|
4
|
-
export declare const
|
|
5
|
-
options: import("@sinclair/typebox").TObject<{
|
|
6
|
-
externalUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
-
baseId: import("@sinclair/typebox").TString;
|
|
8
|
-
baseName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
9
|
-
tableId: import("@sinclair/typebox").TString;
|
|
10
|
-
tableName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
11
|
-
fields: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
12
|
-
id: import("@sinclair/typebox").TString;
|
|
13
|
-
name: import("@sinclair/typebox").TString;
|
|
14
|
-
type: import("@sinclair/typebox").TString;
|
|
15
|
-
}>>>;
|
|
16
|
-
}>;
|
|
17
|
-
provider: import("@sinclair/typebox").TLiteral<"airtable">;
|
|
18
|
-
schema: import("@sinclair/typebox").TAny;
|
|
19
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
20
|
-
options: import("@sinclair/typebox").TObject<{
|
|
21
|
-
spreadsheetId: import("@sinclair/typebox").TString;
|
|
22
|
-
spreadsheetUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
23
|
-
spreadsheetName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
24
|
-
externalUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
25
|
-
}>;
|
|
26
|
-
provider: import("@sinclair/typebox").TLiteral<"google-sheets">;
|
|
27
|
-
schema: import("@sinclair/typebox").TAny;
|
|
28
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
29
|
-
options: import("@sinclair/typebox").TObject<{
|
|
30
|
-
url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
31
|
-
id: import("@sinclair/typebox").TString;
|
|
32
|
-
name: import("@sinclair/typebox").TString;
|
|
33
|
-
properties: import("@sinclair/typebox").TAny;
|
|
34
|
-
}>;
|
|
35
|
-
provider: import("@sinclair/typebox").TLiteral<"notion">;
|
|
36
|
-
schema: import("@sinclair/typebox").TAny;
|
|
37
|
-
}>, import("@sinclair/typebox").TObject<{
|
|
38
|
-
provider: import("@sinclair/typebox").TLiteral<"internal">;
|
|
39
|
-
schema: import("@sinclair/typebox").TAny;
|
|
40
|
-
indexes: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
41
|
-
name: import("@sinclair/typebox").TString;
|
|
42
|
-
fields: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
43
|
-
unique: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
44
|
-
}>>;
|
|
45
|
-
}>]>;
|
|
46
|
-
declare const datarecordManifest: import("@sinclair/typebox").TObject<{
|
|
4
|
+
export declare const genericDatarecord: import("@sinclair/typebox").TObject<{
|
|
47
5
|
provider: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"internal">, import("@sinclair/typebox").TLiteral<"notion">, import("@sinclair/typebox").TLiteral<"google-sheets">, import("@sinclair/typebox").TLiteral<"airtable">]>;
|
|
48
|
-
schema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TAny, import("@sinclair/typebox").TAny, import("@sinclair/typebox").TAny]>;
|
|
49
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
50
|
-
id: import("@sinclair/typebox").TString;
|
|
51
|
-
label: import("@sinclair/typebox").TString;
|
|
52
|
-
}>;
|
|
53
|
-
export declare const internalDatarecordManifest: import("@sinclair/typebox").TObject<{
|
|
54
6
|
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
55
7
|
id: import("@sinclair/typebox").TString;
|
|
56
8
|
label: import("@sinclair/typebox").TString;
|
|
57
|
-
provider: import("@sinclair/typebox").TLiteral<"internal">;
|
|
58
9
|
schema: import("@sinclair/typebox").TAny;
|
|
59
|
-
indexes: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
60
|
-
name: import("@sinclair/typebox").TString;
|
|
61
|
-
fields: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
62
|
-
unique: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
63
|
-
}>>;
|
|
64
10
|
}>;
|
|
65
|
-
export type
|
|
66
|
-
export type
|
|
11
|
+
export type Datarecord = Static<typeof genericDatarecord>;
|
|
12
|
+
export type InternalDatarecord = Extract<Datarecord, {
|
|
13
|
+
provider: "internal";
|
|
14
|
+
}>;
|
|
67
15
|
export declare const datarecordsList: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
68
16
|
provider: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"internal">, import("@sinclair/typebox").TLiteral<"notion">, import("@sinclair/typebox").TLiteral<"google-sheets">, import("@sinclair/typebox").TLiteral<"airtable">]>;
|
|
69
|
-
schema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TAny, import("@sinclair/typebox").TAny, import("@sinclair/typebox").TAny]>;
|
|
70
17
|
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
71
18
|
id: import("@sinclair/typebox").TString;
|
|
72
19
|
label: import("@sinclair/typebox").TString;
|
|
20
|
+
schema: import("@sinclair/typebox").TAny;
|
|
73
21
|
}>>;
|
|
74
22
|
export type DatarecordsList = Static<typeof datarecordsList>;
|
|
75
|
-
export {};
|
|
76
23
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/datarecords/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/datarecords/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,eAAe,iPAK1B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AA8GjE,eAAO,MAAM,iBAAiB;;;;;;EAkB5B,CAAC;AA8BH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC1D,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,QAAQ,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAE/E,eAAO,MAAM,eAAe;;;;;;GAAgC,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import{
|
|
3
|
+
import {
|
|
4
|
+
connectorSchema,
|
|
5
|
+
datarecordsList,
|
|
6
|
+
genericDatarecord
|
|
7
|
+
} from "../chunk-LLNPH3XR.js";
|
|
8
|
+
import "../chunk-OSJ6KGPX.js";
|
|
9
|
+
import "../chunk-7LAWWRU7.js";
|
|
10
|
+
import "../chunk-CSF2WQX2.js";
|
|
11
|
+
import "../chunk-ZGQ3AQBG.js";
|
|
12
|
+
export {
|
|
13
|
+
connectorSchema,
|
|
14
|
+
datarecordsList,
|
|
15
|
+
genericDatarecord
|
|
16
|
+
};
|
|
4
17
|
//# sourceMappingURL=types.js.map
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import "./chunk-ZGQ3AQBG.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/datarecords.ts
|
|
6
|
+
function defineDataRecord(datarecord) {
|
|
7
|
+
return datarecord;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
defineDataRecord
|
|
11
|
+
};
|
|
4
12
|
//# sourceMappingURL=datarecords.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shared/datarecords.ts"],"sourcesContent":["import type { Datarecord } from \"./datarecords/types\";\n\nexport function defineDataRecord<T extends Datarecord>(datarecord: T) {\n return datarecord;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/shared/datarecords.ts"],"sourcesContent":["import type { Datarecord } from \"./datarecords/types\";\n\nexport function defineDataRecord<T extends Datarecord>(datarecord: T) {\n return datarecord;\n}\n"],"mappings":";;;;;AAEO,SAAS,iBAAuC,YAAe;AACpE,SAAO;AACT;","names":[]}
|
|
@@ -1,4 +1,52 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
stringifyObjectValues
|
|
5
|
+
} from "../../../../chunk-OJP4HMJT.js";
|
|
6
|
+
import {
|
|
7
|
+
UnauthorizedError
|
|
8
|
+
} from "../../../../chunk-XZ6WJZHN.js";
|
|
9
|
+
import "../../../../chunk-ZGQ3AQBG.js";
|
|
10
|
+
|
|
11
|
+
// src/shared/datasources/external/facebook/posts/fetcher.ts
|
|
12
|
+
var fetchFacebookPostDatasource = async ({ options, oauth }) => {
|
|
13
|
+
const params = new URLSearchParams({
|
|
14
|
+
...stringifyObjectValues(options),
|
|
15
|
+
fields: [
|
|
16
|
+
"from",
|
|
17
|
+
"permalink_url",
|
|
18
|
+
"name",
|
|
19
|
+
"description",
|
|
20
|
+
"caption",
|
|
21
|
+
"id",
|
|
22
|
+
"is_hidden",
|
|
23
|
+
"message",
|
|
24
|
+
"application",
|
|
25
|
+
"object_id",
|
|
26
|
+
"link",
|
|
27
|
+
"is_published",
|
|
28
|
+
"properties",
|
|
29
|
+
"status_type",
|
|
30
|
+
"story",
|
|
31
|
+
"type",
|
|
32
|
+
"actions",
|
|
33
|
+
"call_to_action",
|
|
34
|
+
"child_attachments"
|
|
35
|
+
].join(","),
|
|
36
|
+
access_token: oauth.config.accessToken
|
|
37
|
+
});
|
|
38
|
+
const response = await fetch(`https://graph.facebook.com/me/posts?${params}`);
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
if (response.status === 401) {
|
|
41
|
+
throw new UnauthorizedError(`fetchFacebookPostDatasource Error: Unauthorized.`);
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`fetchFacebookPostDatasource Error: Response status: ${response.status}`);
|
|
44
|
+
}
|
|
45
|
+
const post = await response.json();
|
|
46
|
+
return post;
|
|
47
|
+
};
|
|
48
|
+
var fetcher_default = fetchFacebookPostDatasource;
|
|
49
|
+
export {
|
|
50
|
+
fetcher_default as default
|
|
51
|
+
};
|
|
4
52
|
//# sourceMappingURL=fetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/shared/datasources/external/facebook/posts/fetcher.ts"],"sourcesContent":["import { facebookPostSchema, type FacebookPostSchema } from \"./schema\";\nimport type { MetaFullOAuthConfig } from \"../../meta/oauth/config\";\nimport { UnauthorizedError } from \"~/shared/errors\";\nimport type { MetaOptions } from \"../../meta/options\";\nimport { stringifyObjectValues } from \"../../../utils\";\nimport type { DatasourceFetcher } from \"~/shared/datasources/fetcher\";\n\nconst fetchFacebookPostDatasource: DatasourceFetcher<\n FacebookPostSchema,\n MetaFullOAuthConfig,\n MetaOptions\n> = async ({ options, oauth }) => {\n const params = new URLSearchParams({\n ...stringifyObjectValues(options),\n fields: [\n \"from\",\n \"permalink_url\",\n \"name\",\n \"description\",\n \"caption\",\n \"id\",\n \"is_hidden\",\n \"message\",\n \"application\",\n \"object_id\",\n \"link\",\n \"is_published\",\n \"properties\",\n \"status_type\",\n \"story\",\n \"type\",\n \"actions\",\n \"call_to_action\",\n \"child_attachments\",\n ].join(\",\"),\n access_token: oauth.config.accessToken,\n });\n\n const response = await fetch(`https://graph.facebook.com/me/posts?${params}`);\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new UnauthorizedError(`fetchFacebookPostDatasource Error: Unauthorized.`);\n }\n throw new Error(`fetchFacebookPostDatasource Error: Response status: ${response.status}`);\n }\n\n const post = (await response.json()) as FacebookPostSchema;\n return post;\n};\n\nexport default fetchFacebookPostDatasource;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/shared/datasources/external/facebook/posts/fetcher.ts"],"sourcesContent":["import { facebookPostSchema, type FacebookPostSchema } from \"./schema\";\nimport type { MetaFullOAuthConfig } from \"../../meta/oauth/config\";\nimport { UnauthorizedError } from \"~/shared/errors\";\nimport type { MetaOptions } from \"../../meta/options\";\nimport { stringifyObjectValues } from \"../../../utils\";\nimport type { DatasourceFetcher } from \"~/shared/datasources/fetcher\";\n\nconst fetchFacebookPostDatasource: DatasourceFetcher<\n FacebookPostSchema,\n MetaFullOAuthConfig,\n MetaOptions\n> = async ({ options, oauth }) => {\n const params = new URLSearchParams({\n ...stringifyObjectValues(options),\n fields: [\n \"from\",\n \"permalink_url\",\n \"name\",\n \"description\",\n \"caption\",\n \"id\",\n \"is_hidden\",\n \"message\",\n \"application\",\n \"object_id\",\n \"link\",\n \"is_published\",\n \"properties\",\n \"status_type\",\n \"story\",\n \"type\",\n \"actions\",\n \"call_to_action\",\n \"child_attachments\",\n ].join(\",\"),\n access_token: oauth.config.accessToken,\n });\n\n const response = await fetch(`https://graph.facebook.com/me/posts?${params}`);\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new UnauthorizedError(`fetchFacebookPostDatasource Error: Unauthorized.`);\n }\n throw new Error(`fetchFacebookPostDatasource Error: Response status: ${response.status}`);\n }\n\n const post = (await response.json()) as FacebookPostSchema;\n return post;\n};\n\nexport default fetchFacebookPostDatasource;\n"],"mappings":";;;;;;;;;;;AAOA,IAAM,8BAIF,OAAO,EAAE,SAAS,MAAM,MAAM;AAChC,QAAM,SAAS,IAAI,gBAAgB;AAAA,IACjC,GAAG,sBAAsB,OAAO;AAAA,IAChC,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,GAAG;AAAA,IACV,cAAc,MAAM,OAAO;AAAA,EAC7B,CAAC;AAED,QAAM,WAAW,MAAM,MAAM,uCAAuC,MAAM,EAAE;AAE5E,MAAI,CAAC,SAAS,IAAI;AAChB,QAAI,SAAS,WAAW,KAAK;AAC3B,YAAM,IAAI,kBAAkB,kDAAkD;AAAA,IAChF;AACA,UAAM,IAAI,MAAM,uDAAuD,SAAS,MAAM,EAAE;AAAA,EAC1F;AAEA,QAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,SAAO;AACT;AAEA,IAAO,kBAAQ;","names":[]}
|
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import "../../../../chunk-ZGQ3AQBG.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/datasources/external/facebook/posts/schema.ts
|
|
6
|
+
import { Type } from "@sinclair/typebox";
|
|
7
|
+
var facebookPostSchema = Type.Object({
|
|
8
|
+
data: Type.Array(
|
|
9
|
+
Type.Object({
|
|
10
|
+
from: Type.Object({
|
|
11
|
+
name: Type.String(),
|
|
12
|
+
id: Type.String()
|
|
13
|
+
}),
|
|
14
|
+
id: Type.String(),
|
|
15
|
+
permalink_url: Type.String(),
|
|
16
|
+
is_hidden: Type.Boolean(),
|
|
17
|
+
message: Type.Optional(Type.String()),
|
|
18
|
+
object_id: Type.String(),
|
|
19
|
+
link: Type.String(),
|
|
20
|
+
is_published: Type.Boolean(),
|
|
21
|
+
status_type: Type.String(),
|
|
22
|
+
type: Type.String(),
|
|
23
|
+
actions: Type.Array(
|
|
24
|
+
Type.Object({
|
|
25
|
+
name: Type.String(),
|
|
26
|
+
link: Type.String()
|
|
27
|
+
})
|
|
28
|
+
)
|
|
29
|
+
})
|
|
30
|
+
),
|
|
31
|
+
paging: Type.Object({
|
|
32
|
+
previous: Type.Optional(Type.String()),
|
|
33
|
+
next: Type.Optional(Type.String())
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
export {
|
|
37
|
+
facebookPostSchema
|
|
38
|
+
};
|
|
4
39
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/shared/datasources/external/facebook/posts/schema.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const facebookPostSchema = Type.Object({\n data: Type.Array(\n Type.Object({\n from: Type.Object({\n name: Type.String(),\n id: Type.String(),\n }),\n id: Type.String(),\n permalink_url: Type.String(),\n is_hidden: Type.Boolean(),\n message: Type.Optional(Type.String()),\n object_id: Type.String(),\n link: Type.String(),\n is_published: Type.Boolean(),\n status_type: Type.String(),\n type: Type.String(),\n actions: Type.Array(\n Type.Object({\n name: Type.String(),\n link: Type.String(),\n }),\n ),\n }),\n ),\n paging: Type.Object({\n previous: Type.Optional(Type.String()),\n next: Type.Optional(Type.String()),\n }),\n});\n\nexport type FacebookPostSchema = Static<typeof facebookPostSchema>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/shared/datasources/external/facebook/posts/schema.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const facebookPostSchema = Type.Object({\n data: Type.Array(\n Type.Object({\n from: Type.Object({\n name: Type.String(),\n id: Type.String(),\n }),\n id: Type.String(),\n permalink_url: Type.String(),\n is_hidden: Type.Boolean(),\n message: Type.Optional(Type.String()),\n object_id: Type.String(),\n link: Type.String(),\n is_published: Type.Boolean(),\n status_type: Type.String(),\n type: Type.String(),\n actions: Type.Array(\n Type.Object({\n name: Type.String(),\n link: Type.String(),\n }),\n ),\n }),\n ),\n paging: Type.Object({\n previous: Type.Optional(Type.String()),\n next: Type.Optional(Type.String()),\n }),\n});\n\nexport type FacebookPostSchema = Static<typeof facebookPostSchema>;\n"],"mappings":";;;;;AAAA,SAAS,YAAyB;AAE3B,IAAM,qBAAqB,KAAK,OAAO;AAAA,EAC5C,MAAM,KAAK;AAAA,IACT,KAAK,OAAO;AAAA,MACV,MAAM,KAAK,OAAO;AAAA,QAChB,MAAM,KAAK,OAAO;AAAA,QAClB,IAAI,KAAK,OAAO;AAAA,MAClB,CAAC;AAAA,MACD,IAAI,KAAK,OAAO;AAAA,MAChB,eAAe,KAAK,OAAO;AAAA,MAC3B,WAAW,KAAK,QAAQ;AAAA,MACxB,SAAS,KAAK,SAAS,KAAK,OAAO,CAAC;AAAA,MACpC,WAAW,KAAK,OAAO;AAAA,MACvB,MAAM,KAAK,OAAO;AAAA,MAClB,cAAc,KAAK,QAAQ;AAAA,MAC3B,aAAa,KAAK,OAAO;AAAA,MACzB,MAAM,KAAK,OAAO;AAAA,MAClB,SAAS,KAAK;AAAA,QACZ,KAAK,OAAO;AAAA,UACV,MAAM,KAAK,OAAO;AAAA,UAClB,MAAM,KAAK,OAAO;AAAA,QACpB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,QAAQ,KAAK,OAAO;AAAA,IAClB,UAAU,KAAK,SAAS,KAAK,OAAO,CAAC;AAAA,IACrC,MAAM,KAAK,SAAS,KAAK,OAAO,CAAC;AAAA,EACnC,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
createPlaceholderReplacer,
|
|
5
|
+
placeholderRx
|
|
6
|
+
} from "../../../chunk-OJP4HMJT.js";
|
|
7
|
+
import "../../../chunk-ZGQ3AQBG.js";
|
|
8
|
+
|
|
9
|
+
// src/shared/datasources/external/http-json/fetcher.ts
|
|
10
|
+
var fetchHttpJSON = async ({
|
|
11
|
+
options,
|
|
12
|
+
pageAttributes
|
|
13
|
+
}) => {
|
|
14
|
+
const replacer = createPlaceholderReplacer(pageAttributes);
|
|
15
|
+
const url = options.url.replace(placeholderRx, replacer);
|
|
16
|
+
const headers = {};
|
|
17
|
+
if (options.headers) {
|
|
18
|
+
for (const [key, value] of Object.entries(options.headers ?? {})) {
|
|
19
|
+
headers[key] = value.replace(placeholderRx, replacer);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const response = await fetch(url, { headers });
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new Error(`fetchHttpJSON Error: Response status: ${response.status}`);
|
|
25
|
+
}
|
|
26
|
+
return response.json();
|
|
27
|
+
};
|
|
28
|
+
var fetcher_default = fetchHttpJSON;
|
|
29
|
+
export {
|
|
30
|
+
fetcher_default as default
|
|
31
|
+
};
|
|
4
32
|
//# sourceMappingURL=fetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/datasources/external/http-json/fetcher.ts"],"sourcesContent":["import type { DatasourceFetcher } from \"../../fetcher\";\nimport { createPlaceholderReplacer, placeholderRx } from \"../../utils\";\nimport type { HttpJsonOptions } from \"./options\";\n\n/**\n * For this fetcher, validation is done outside of the fetcher.\n */\nconst fetchHttpJSON: DatasourceFetcher<unknown, null, HttpJsonOptions> = async ({\n options,\n pageAttributes,\n}) => {\n const replacer = createPlaceholderReplacer(pageAttributes);\n const url = options.url.replace(placeholderRx, replacer);\n const headers: Record<string, string> = {};\n\n if (options.headers) {\n for (const [key, value] of Object.entries(options.headers ?? {})) {\n headers[key] = (value as string).replace(placeholderRx, replacer);\n }\n }\n\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new Error(`fetchHttpJSON Error: Response status: ${response.status}`);\n }\n\n return response.json();\n};\n\nexport default fetchHttpJSON;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/datasources/external/http-json/fetcher.ts"],"sourcesContent":["import type { DatasourceFetcher } from \"../../fetcher\";\nimport { createPlaceholderReplacer, placeholderRx } from \"../../utils\";\nimport type { HttpJsonOptions } from \"./options\";\n\n/**\n * For this fetcher, validation is done outside of the fetcher.\n */\nconst fetchHttpJSON: DatasourceFetcher<unknown, null, HttpJsonOptions> = async ({\n options,\n pageAttributes,\n}) => {\n const replacer = createPlaceholderReplacer(pageAttributes);\n const url = options.url.replace(placeholderRx, replacer);\n const headers: Record<string, string> = {};\n\n if (options.headers) {\n for (const [key, value] of Object.entries(options.headers ?? {})) {\n headers[key] = (value as string).replace(placeholderRx, replacer);\n }\n }\n\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new Error(`fetchHttpJSON Error: Response status: ${response.status}`);\n }\n\n return response.json();\n};\n\nexport default fetchHttpJSON;\n"],"mappings":";;;;;;;;;AAOA,IAAM,gBAAmE,OAAO;AAAA,EAC9E;AAAA,EACA;AACF,MAAM;AACJ,QAAM,WAAW,0BAA0B,cAAc;AACzD,QAAM,MAAM,QAAQ,IAAI,QAAQ,eAAe,QAAQ;AACvD,QAAM,UAAkC,CAAC;AAEzC,MAAI,QAAQ,SAAS;AACnB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,WAAW,CAAC,CAAC,GAAG;AAChE,cAAQ,GAAG,IAAK,MAAiB,QAAQ,eAAe,QAAQ;AAAA,IAClE;AAAA,EACF;AAEA,QAAM,WAAW,MAAM,MAAM,KAAK,EAAE,QAAQ,CAAC;AAE7C,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,yCAAyC,SAAS,MAAM,EAAE;AAAA,EAC5E;AAEA,SAAO,SAAS,KAAK;AACvB;AAEA,IAAO,kBAAQ;","names":[]}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import "../../../chunk-ZGQ3AQBG.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/datasources/external/http-json/options.ts
|
|
6
|
+
import { Type } from "@sinclair/typebox";
|
|
7
|
+
var httpJsonOptions = Type.Object({
|
|
8
|
+
url: Type.String({ format: "uri" }),
|
|
9
|
+
headers: Type.Optional(Type.Record(Type.String(), Type.String()))
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
httpJsonOptions
|
|
13
|
+
};
|
|
4
14
|
//# sourceMappingURL=options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/datasources/external/http-json/options.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const httpJsonOptions = Type.Object({\n url: Type.String({ format: \"uri\" }),\n headers: Type.Optional(Type.Record(Type.String(), Type.String())),\n});\n\nexport type HttpJsonOptions = Static<typeof httpJsonOptions>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/datasources/external/http-json/options.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const httpJsonOptions = Type.Object({\n url: Type.String({ format: \"uri\" }),\n headers: Type.Optional(Type.Record(Type.String(), Type.String())),\n});\n\nexport type HttpJsonOptions = Static<typeof httpJsonOptions>;\n"],"mappings":";;;;;AAAA,SAAS,YAAyB;AAE3B,IAAM,kBAAkB,KAAK,OAAO;AAAA,EACzC,KAAK,KAAK,OAAO,EAAE,QAAQ,MAAM,CAAC;AAAA,EAClC,SAAS,KAAK,SAAS,KAAK,OAAO,KAAK,OAAO,GAAG,KAAK,OAAO,CAAC,CAAC;AAClE,CAAC;","names":[]}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import "../../../chunk-ZGQ3AQBG.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/datasources/external/http-json/schema.ts
|
|
6
|
+
import { Type } from "@sinclair/typebox";
|
|
7
|
+
var jsonObjectSchema = Type.Object({}, { additionalProperties: true });
|
|
8
|
+
var jsonArraySchema = Type.Array(jsonObjectSchema, { title: "Http JSON" });
|
|
9
|
+
export {
|
|
10
|
+
jsonArraySchema,
|
|
11
|
+
jsonObjectSchema
|
|
12
|
+
};
|
|
4
13
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/datasources/external/http-json/schema.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const jsonObjectSchema = Type.Object({}, { additionalProperties: true });\nexport const jsonArraySchema = Type.Array(jsonObjectSchema, { title: \"Http JSON\" });\n\nexport type JSONArraySchema = Static<typeof jsonArraySchema>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/datasources/external/http-json/schema.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const jsonObjectSchema = Type.Object({}, { additionalProperties: true });\nexport const jsonArraySchema = Type.Array(jsonObjectSchema, { title: \"Http JSON\" });\n\nexport type JSONArraySchema = Static<typeof jsonArraySchema>;\n"],"mappings":";;;;;AAAA,SAAS,YAAyB;AAE3B,IAAM,mBAAmB,KAAK,OAAO,CAAC,GAAG,EAAE,sBAAsB,KAAK,CAAC;AACvE,IAAM,kBAAkB,KAAK,MAAM,kBAAkB,EAAE,OAAO,YAAY,CAAC;","names":[]}
|
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
stringifyObjectValues
|
|
5
|
+
} from "../../../../chunk-OJP4HMJT.js";
|
|
6
|
+
import {
|
|
7
|
+
UnauthorizedError
|
|
8
|
+
} from "../../../../chunk-XZ6WJZHN.js";
|
|
9
|
+
import "../../../../chunk-ZGQ3AQBG.js";
|
|
10
|
+
|
|
11
|
+
// src/shared/datasources/external/instagram/feed/fetcher.ts
|
|
12
|
+
var fetchInstagramFeedDatasource = async ({ options, oauth }) => {
|
|
13
|
+
const params = new URLSearchParams({
|
|
14
|
+
...stringifyObjectValues(options),
|
|
15
|
+
access_token: oauth.config.accessToken,
|
|
16
|
+
fields: ["id", "caption", "timestamp", "thumbnail_url", "media_url", "permalink", "media_type"].join(",")
|
|
17
|
+
});
|
|
18
|
+
const response = await fetch(`https://graph.instagram.com/me/media?${params.toString()}`);
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
if (response.status === 401) {
|
|
21
|
+
throw new UnauthorizedError(`fetchInstagramFeedDatasource Error: Unauthorized.`);
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`fetchInstagramFeedDatasource Error: Response status: ${response.status}`);
|
|
24
|
+
}
|
|
25
|
+
const feed = await response.json();
|
|
26
|
+
return feed;
|
|
27
|
+
};
|
|
28
|
+
var fetcher_default = fetchInstagramFeedDatasource;
|
|
29
|
+
export {
|
|
30
|
+
fetcher_default as default
|
|
31
|
+
};
|
|
4
32
|
//# sourceMappingURL=fetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/shared/datasources/external/instagram/feed/fetcher.ts"],"sourcesContent":["import type { InstagramFeedSchema } from \"./schema\";\nimport type { MetaFullOAuthConfig } from \"~/shared/datasources/external/meta/oauth/config\";\nimport { UnauthorizedError } from \"~/shared/errors\";\nimport type { MetaOptions } from \"~/shared/datasources/external/meta/options\";\nimport { stringifyObjectValues } from \"~/shared/datasources/utils\";\nimport type { DatasourceFetcher } from \"~/shared/datasources/fetcher\";\n\nconst fetchInstagramFeedDatasource: DatasourceFetcher<\n InstagramFeedSchema,\n MetaFullOAuthConfig,\n MetaOptions\n> = async ({ options, oauth }) => {\n const params = new URLSearchParams({\n ...stringifyObjectValues(options),\n access_token: oauth.config.accessToken,\n fields: [\"id\", \"caption\", \"timestamp\", \"thumbnail_url\", \"media_url\", \"permalink\", \"media_type\"].join(\",\"),\n });\n\n const response = await fetch(`https://graph.instagram.com/me/media?${params.toString()}`);\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new UnauthorizedError(`fetchInstagramFeedDatasource Error: Unauthorized.`);\n }\n throw new Error(`fetchInstagramFeedDatasource Error: Response status: ${response.status}`);\n }\n\n const feed = (await response.json()) as InstagramFeedSchema;\n\n return feed;\n};\n\nexport default fetchInstagramFeedDatasource;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/shared/datasources/external/instagram/feed/fetcher.ts"],"sourcesContent":["import type { InstagramFeedSchema } from \"./schema\";\nimport type { MetaFullOAuthConfig } from \"~/shared/datasources/external/meta/oauth/config\";\nimport { UnauthorizedError } from \"~/shared/errors\";\nimport type { MetaOptions } from \"~/shared/datasources/external/meta/options\";\nimport { stringifyObjectValues } from \"~/shared/datasources/utils\";\nimport type { DatasourceFetcher } from \"~/shared/datasources/fetcher\";\n\nconst fetchInstagramFeedDatasource: DatasourceFetcher<\n InstagramFeedSchema,\n MetaFullOAuthConfig,\n MetaOptions\n> = async ({ options, oauth }) => {\n const params = new URLSearchParams({\n ...stringifyObjectValues(options),\n access_token: oauth.config.accessToken,\n fields: [\"id\", \"caption\", \"timestamp\", \"thumbnail_url\", \"media_url\", \"permalink\", \"media_type\"].join(\",\"),\n });\n\n const response = await fetch(`https://graph.instagram.com/me/media?${params.toString()}`);\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new UnauthorizedError(`fetchInstagramFeedDatasource Error: Unauthorized.`);\n }\n throw new Error(`fetchInstagramFeedDatasource Error: Response status: ${response.status}`);\n }\n\n const feed = (await response.json()) as InstagramFeedSchema;\n\n return feed;\n};\n\nexport default fetchInstagramFeedDatasource;\n"],"mappings":";;;;;;;;;;;AAOA,IAAM,+BAIF,OAAO,EAAE,SAAS,MAAM,MAAM;AAChC,QAAM,SAAS,IAAI,gBAAgB;AAAA,IACjC,GAAG,sBAAsB,OAAO;AAAA,IAChC,cAAc,MAAM,OAAO;AAAA,IAC3B,QAAQ,CAAC,MAAM,WAAW,aAAa,iBAAiB,aAAa,aAAa,YAAY,EAAE,KAAK,GAAG;AAAA,EAC1G,CAAC;AAED,QAAM,WAAW,MAAM,MAAM,wCAAwC,OAAO,SAAS,CAAC,EAAE;AAExF,MAAI,CAAC,SAAS,IAAI;AAChB,QAAI,SAAS,WAAW,KAAK;AAC3B,YAAM,IAAI,kBAAkB,mDAAmD;AAAA,IACjF;AACA,UAAM,IAAI,MAAM,wDAAwD,SAAS,MAAM,EAAE;AAAA,EAC3F;AAEA,QAAM,OAAQ,MAAM,SAAS,KAAK;AAElC,SAAO;AACT;AAEA,IAAO,kBAAQ;","names":[]}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import "../../../../chunk-ZGQ3AQBG.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/datasources/external/instagram/feed/schema.ts
|
|
6
|
+
import { Type } from "@sinclair/typebox";
|
|
7
|
+
var instagramFeedSchema = Type.Object({
|
|
8
|
+
data: Type.Array(
|
|
9
|
+
Type.Object({
|
|
10
|
+
id: Type.String(),
|
|
11
|
+
caption: Type.String(),
|
|
12
|
+
timestamp: Type.String(),
|
|
13
|
+
media_url: Type.String(),
|
|
14
|
+
permalink: Type.String(),
|
|
15
|
+
media_type: Type.Union([Type.Literal("IMAGE"), Type.Literal("VIDEO"), Type.Literal("CAROUSEL_ALBUM")])
|
|
16
|
+
})
|
|
17
|
+
),
|
|
18
|
+
paging: Type.Object({
|
|
19
|
+
cursors: Type.Object({
|
|
20
|
+
before: Type.Optional(Type.String()),
|
|
21
|
+
after: Type.Optional(Type.String())
|
|
22
|
+
}),
|
|
23
|
+
next: Type.Optional(Type.String())
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
instagramFeedSchema
|
|
28
|
+
};
|
|
4
29
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/shared/datasources/external/instagram/feed/schema.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const instagramFeedSchema = Type.Object({\n data: Type.Array(\n Type.Object({\n id: Type.String(),\n caption: Type.String(),\n timestamp: Type.String(),\n media_url: Type.String(),\n permalink: Type.String(),\n media_type: Type.Union([Type.Literal(\"IMAGE\"), Type.Literal(\"VIDEO\"), Type.Literal(\"CAROUSEL_ALBUM\")]),\n }),\n ),\n paging: Type.Object({\n cursors: Type.Object({\n before: Type.Optional(Type.String()),\n after: Type.Optional(Type.String()),\n }),\n next: Type.Optional(Type.String()),\n }),\n});\n\nexport type InstagramFeedSchema = Static<typeof instagramFeedSchema>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/shared/datasources/external/instagram/feed/schema.ts"],"sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\n\nexport const instagramFeedSchema = Type.Object({\n data: Type.Array(\n Type.Object({\n id: Type.String(),\n caption: Type.String(),\n timestamp: Type.String(),\n media_url: Type.String(),\n permalink: Type.String(),\n media_type: Type.Union([Type.Literal(\"IMAGE\"), Type.Literal(\"VIDEO\"), Type.Literal(\"CAROUSEL_ALBUM\")]),\n }),\n ),\n paging: Type.Object({\n cursors: Type.Object({\n before: Type.Optional(Type.String()),\n after: Type.Optional(Type.String()),\n }),\n next: Type.Optional(Type.String()),\n }),\n});\n\nexport type InstagramFeedSchema = Static<typeof instagramFeedSchema>;\n"],"mappings":";;;;;AAAA,SAAS,YAAyB;AAE3B,IAAM,sBAAsB,KAAK,OAAO;AAAA,EAC7C,MAAM,KAAK;AAAA,IACT,KAAK,OAAO;AAAA,MACV,IAAI,KAAK,OAAO;AAAA,MAChB,SAAS,KAAK,OAAO;AAAA,MACrB,WAAW,KAAK,OAAO;AAAA,MACvB,WAAW,KAAK,OAAO;AAAA,MACvB,WAAW,KAAK,OAAO;AAAA,MACvB,YAAY,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,GAAG,KAAK,QAAQ,OAAO,GAAG,KAAK,QAAQ,gBAAgB,CAAC,CAAC;AAAA,IACvG,CAAC;AAAA,EACH;AAAA,EACA,QAAQ,KAAK,OAAO;AAAA,IAClB,SAAS,KAAK,OAAO;AAAA,MACnB,QAAQ,KAAK,SAAS,KAAK,OAAO,CAAC;AAAA,MACnC,OAAO,KAAK,SAAS,KAAK,OAAO,CAAC;AAAA,IACpC,CAAC;AAAA,IACD,MAAM,KAAK,SAAS,KAAK,OAAO,CAAC;AAAA,EACnC,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import{
|
|
3
|
+
import {
|
|
4
|
+
fetcher_default
|
|
5
|
+
} from "../../../../chunk-KT7SSWMM.js";
|
|
6
|
+
import "../../../../chunk-ZGQ3AQBG.js";
|
|
7
|
+
export {
|
|
8
|
+
fetcher_default as default
|
|
9
|
+
};
|
|
4
10
|
//# sourceMappingURL=fetcher.js.map
|