@distilled.cloud/scaleway 0.0.0-stage → 1.0.0-rc.21
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/LICENSE +201 -0
- package/README.md +175 -2
- package/lib/.lazy.json +1 -0
- package/lib/_bundle/lazy.js +4 -0
- package/lib/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/credentials.d.ts +44 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +1 -0
- package/lib/errors.d.ts +285 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +1 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/pagination.d.ts +10 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +1 -0
- package/lib/protocol.d.ts +48 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +1 -0
- package/lib/retry.d.ts +31 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +1 -0
- package/lib/services/account_contract_v3.d.ts +124 -0
- package/lib/services/account_contract_v3.d.ts.map +1 -0
- package/lib/services/account_contract_v3.js +2 -0
- package/lib/services/account_contract_v3.js.map +1 -0
- package/lib/services/account_iso_code_v3.d.ts +44 -0
- package/lib/services/account_iso_code_v3.d.ts.map +1 -0
- package/lib/services/account_iso_code_v3.js +2 -0
- package/lib/services/account_iso_code_v3.js.map +1 -0
- package/lib/services/account_organization_v3.d.ts +290 -0
- package/lib/services/account_organization_v3.d.ts.map +1 -0
- package/lib/services/account_organization_v3.js +2 -0
- package/lib/services/account_organization_v3.js.map +1 -0
- package/lib/services/account_project_v3.d.ts +173 -0
- package/lib/services/account_project_v3.d.ts.map +1 -0
- package/lib/services/account_project_v3.js +2 -0
- package/lib/services/account_project_v3.js.map +1 -0
- package/lib/services/account_unauthenticated_user_v3.d.ts +479 -0
- package/lib/services/account_unauthenticated_user_v3.d.ts.map +1 -0
- package/lib/services/account_unauthenticated_user_v3.js +35 -0
- package/lib/services/account_unauthenticated_user_v3.js.map +1 -0
- package/lib/services/account_unauthenticated_v3.d.ts +18 -0
- package/lib/services/account_unauthenticated_v3.d.ts.map +1 -0
- package/lib/services/account_unauthenticated_v3.js +2 -0
- package/lib/services/account_unauthenticated_v3.js.map +1 -0
- package/lib/services/account_user_v3.d.ts +522 -0
- package/lib/services/account_user_v3.d.ts.map +1 -0
- package/lib/services/account_user_v3.js +39 -0
- package/lib/services/account_user_v3.js.map +1 -0
- package/lib/services/annotations_v1.d.ts +260 -0
- package/lib/services/annotations_v1.d.ts.map +1 -0
- package/lib/services/annotations_v1.js +2 -0
- package/lib/services/annotations_v1.js.map +1 -0
- package/lib/services/baremetal_private_network_v1.d.ts +95 -0
- package/lib/services/baremetal_private_network_v1.d.ts.map +1 -0
- package/lib/services/baremetal_private_network_v1.js +2 -0
- package/lib/services/baremetal_private_network_v1.js.map +1 -0
- package/lib/services/baremetal_private_network_v3.d.ts +110 -0
- package/lib/services/baremetal_private_network_v3.d.ts.map +1 -0
- package/lib/services/baremetal_private_network_v3.js +2 -0
- package/lib/services/baremetal_private_network_v3.js.map +1 -0
- package/lib/services/baremetal_v1.d.ts +1089 -0
- package/lib/services/baremetal_v1.d.ts.map +1 -0
- package/lib/services/baremetal_v1.js +52 -0
- package/lib/services/baremetal_v1.js.map +1 -0
- package/lib/services/billing_electronic_billing_v2.d.ts +86 -0
- package/lib/services/billing_electronic_billing_v2.d.ts.map +1 -0
- package/lib/services/billing_electronic_billing_v2.js +2 -0
- package/lib/services/billing_electronic_billing_v2.js.map +1 -0
- package/lib/services/billing_v2.d.ts +187 -0
- package/lib/services/billing_v2.d.ts.map +1 -0
- package/lib/services/billing_v2.js +2 -0
- package/lib/services/billing_v2.js.map +1 -0
- package/lib/services/block_v1.d.ts +401 -0
- package/lib/services/block_v1.d.ts.map +1 -0
- package/lib/services/block_v1.js +27 -0
- package/lib/services/block_v1.js.map +1 -0
- package/lib/services/cockpit_global_v1.d.ts +75 -0
- package/lib/services/cockpit_global_v1.d.ts.map +1 -0
- package/lib/services/cockpit_global_v1.js +2 -0
- package/lib/services/cockpit_global_v1.js.map +1 -0
- package/lib/services/cockpit_regional_v1.d.ts +739 -0
- package/lib/services/cockpit_regional_v1.d.ts.map +1 -0
- package/lib/services/cockpit_regional_v1.js +47 -0
- package/lib/services/cockpit_regional_v1.js.map +1 -0
- package/lib/services/containers_v1.d.ts +822 -0
- package/lib/services/containers_v1.d.ts.map +1 -0
- package/lib/services/containers_v1.js +39 -0
- package/lib/services/containers_v1.js.map +1 -0
- package/lib/services/dedibox_billing_v1.d.ts +151 -0
- package/lib/services/dedibox_billing_v1.d.ts.map +1 -0
- package/lib/services/dedibox_billing_v1.js +2 -0
- package/lib/services/dedibox_billing_v1.js.map +1 -0
- package/lib/services/dedibox_ipv6_block_v1.d.ts +119 -0
- package/lib/services/dedibox_ipv6_block_v1.d.ts.map +1 -0
- package/lib/services/dedibox_ipv6_block_v1.js +2 -0
- package/lib/services/dedibox_ipv6_block_v1.js.map +1 -0
- package/lib/services/dedibox_rpn_san_v1.d.ts +486 -0
- package/lib/services/dedibox_rpn_san_v1.d.ts.map +1 -0
- package/lib/services/dedibox_rpn_san_v1.js +2 -0
- package/lib/services/dedibox_rpn_san_v1.js.map +1 -0
- package/lib/services/dedibox_rpn_v1.d.ts +68 -0
- package/lib/services/dedibox_rpn_v1.d.ts.map +1 -0
- package/lib/services/dedibox_rpn_v1.js +2 -0
- package/lib/services/dedibox_rpn_v1.js.map +1 -0
- package/lib/services/dedibox_rpn_v1_v1.d.ts +687 -0
- package/lib/services/dedibox_rpn_v1_v1.d.ts.map +1 -0
- package/lib/services/dedibox_rpn_v1_v1.js +30 -0
- package/lib/services/dedibox_rpn_v1_v1.js.map +1 -0
- package/lib/services/dedibox_rpn_v2_v1.d.ts +646 -0
- package/lib/services/dedibox_rpn_v2_v1.d.ts.map +1 -0
- package/lib/services/dedibox_rpn_v2_v1.js +27 -0
- package/lib/services/dedibox_rpn_v2_v1.js.map +1 -0
- package/lib/services/dedibox_v1.d.ts +1351 -0
- package/lib/services/dedibox_v1.d.ts.map +1 -0
- package/lib/services/dedibox_v1.js +70 -0
- package/lib/services/dedibox_v1.js.map +1 -0
- package/lib/services/generative_apis_openai_v1.d.ts +772 -0
- package/lib/services/generative_apis_openai_v1.d.ts.map +1 -0
- package/lib/services/generative_apis_openai_v1.js +24 -0
- package/lib/services/generative_apis_openai_v1.js.map +1 -0
- package/lib/services/generative_apis_v1.d.ts +82 -0
- package/lib/services/generative_apis_v1.d.ts.map +1 -0
- package/lib/services/generative_apis_v1.js +2 -0
- package/lib/services/generative_apis_v1.js.map +1 -0
- package/lib/services/index.d.ts +57 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +56 -0
- package/lib/services/inference_v1.d.ts +460 -0
- package/lib/services/inference_v1.d.ts.map +1 -0
- package/lib/services/inference_v1.js +33 -0
- package/lib/services/inference_v1.js.map +1 -0
- package/lib/services/instance_v1.d.ts +2183 -0
- package/lib/services/instance_v1.d.ts.map +1 -0
- package/lib/services/instance_v1.js +112 -0
- package/lib/services/instance_v1.js.map +1 -0
- package/lib/services/iot_v1.d.ts +837 -0
- package/lib/services/iot_v1.d.ts.map +1 -0
- package/lib/services/iot_v1.js +50 -0
- package/lib/services/iot_v1.js.map +1 -0
- package/lib/services/ipam_v1.d.ts +244 -0
- package/lib/services/ipam_v1.d.ts.map +1 -0
- package/lib/services/ipam_v1.js +2 -0
- package/lib/services/ipam_v1.js.map +1 -0
- package/lib/services/k8s_v1.d.ts +1223 -0
- package/lib/services/k8s_v1.d.ts.map +1 -0
- package/lib/services/k8s_v1.js +61 -0
- package/lib/services/k8s_v1.js.map +1 -0
- package/lib/services/lb_zoned_v1.d.ts +1517 -0
- package/lib/services/lb_zoned_v1.d.ts.map +1 -0
- package/lib/services/lb_zoned_v1.js +75 -0
- package/lib/services/lb_zoned_v1.js.map +1 -0
- package/lib/services/marketplace_console_v2.d.ts +72 -0
- package/lib/services/marketplace_console_v2.d.ts.map +1 -0
- package/lib/services/marketplace_console_v2.js +2 -0
- package/lib/services/marketplace_console_v2.js.map +1 -0
- package/lib/services/marketplace_v2.d.ts +169 -0
- package/lib/services/marketplace_v2.d.ts.map +1 -0
- package/lib/services/marketplace_v2.js +2 -0
- package/lib/services/marketplace_v2.js.map +1 -0
- package/lib/services/mongodb_v1.d.ts +698 -0
- package/lib/services/mongodb_v1.d.ts.map +1 -0
- package/lib/services/mongodb_v1.js +43 -0
- package/lib/services/mongodb_v1.js.map +1 -0
- package/lib/services/partner_v1.d.ts +142 -0
- package/lib/services/partner_v1.d.ts.map +1 -0
- package/lib/services/partner_v1.js +2 -0
- package/lib/services/partner_v1.js.map +1 -0
- package/lib/services/rdb_encryption_v1.d.ts +17 -0
- package/lib/services/rdb_encryption_v1.d.ts.map +1 -0
- package/lib/services/rdb_encryption_v1.js +2 -0
- package/lib/services/rdb_encryption_v1.js.map +1 -0
- package/lib/services/rdb_v1.d.ts +1422 -0
- package/lib/services/rdb_v1.d.ts.map +1 -0
- package/lib/services/rdb_v1.js +87 -0
- package/lib/services/rdb_v1.js.map +1 -0
- package/lib/services/redis_v1.d.ts +602 -0
- package/lib/services/redis_v1.d.ts.map +1 -0
- package/lib/services/redis_v1.js +42 -0
- package/lib/services/redis_v1.js.map +1 -0
- package/lib/services/registry_v1.d.ts +281 -0
- package/lib/services/registry_v1.d.ts.map +1 -0
- package/lib/services/registry_v1.js +2 -0
- package/lib/services/registry_v1.js.map +1 -0
- package/lib/services/reseller_v1.d.ts +81 -0
- package/lib/services/reseller_v1.d.ts.map +1 -0
- package/lib/services/reseller_v1.js +2 -0
- package/lib/services/reseller_v1.js.map +1 -0
- package/lib/services/vpc_gw_v2.d.ts +635 -0
- package/lib/services/vpc_gw_v2.d.ts.map +1 -0
- package/lib/services/vpc_gw_v2.js +46 -0
- package/lib/services/vpc_gw_v2.js.map +1 -0
- package/lib/services/vpc_private_network_with_nics_v2.d.ts +114 -0
- package/lib/services/vpc_private_network_with_nics_v2.d.ts.map +1 -0
- package/lib/services/vpc_private_network_with_nics_v2.js +2 -0
- package/lib/services/vpc_private_network_with_nics_v2.js.map +1 -0
- package/lib/services/vpc_routes_with_nexthop_v2.d.ts +87 -0
- package/lib/services/vpc_routes_with_nexthop_v2.d.ts.map +1 -0
- package/lib/services/vpc_routes_with_nexthop_v2.js +2 -0
- package/lib/services/vpc_routes_with_nexthop_v2.js.map +1 -0
- package/lib/services/vpc_v2.d.ts +875 -0
- package/lib/services/vpc_v2.d.ts.map +1 -0
- package/lib/services/vpc_v2.js +54 -0
- package/lib/services/vpc_v2.js.map +1 -0
- package/lib/services/webhosting_backup_v1.d.ts +182 -0
- package/lib/services/webhosting_backup_v1.d.ts.map +1 -0
- package/lib/services/webhosting_backup_v1.js +2 -0
- package/lib/services/webhosting_backup_v1.js.map +1 -0
- package/lib/services/webhosting_control_panel_v1.d.ts +37 -0
- package/lib/services/webhosting_control_panel_v1.d.ts.map +1 -0
- package/lib/services/webhosting_control_panel_v1.js +2 -0
- package/lib/services/webhosting_control_panel_v1.js.map +1 -0
- package/lib/services/webhosting_database_v1.d.ts +195 -0
- package/lib/services/webhosting_database_v1.d.ts.map +1 -0
- package/lib/services/webhosting_database_v1.js +2 -0
- package/lib/services/webhosting_database_v1.js.map +1 -0
- package/lib/services/webhosting_dedibox_v1.d.ts +232 -0
- package/lib/services/webhosting_dedibox_v1.d.ts.map +1 -0
- package/lib/services/webhosting_dedibox_v1.js +2 -0
- package/lib/services/webhosting_dedibox_v1.js.map +1 -0
- package/lib/services/webhosting_dns_v1.d.ts +177 -0
- package/lib/services/webhosting_dns_v1.d.ts.map +1 -0
- package/lib/services/webhosting_dns_v1.js +2 -0
- package/lib/services/webhosting_dns_v1.js.map +1 -0
- package/lib/services/webhosting_free_domain_v1.d.ts +51 -0
- package/lib/services/webhosting_free_domain_v1.d.ts.map +1 -0
- package/lib/services/webhosting_free_domain_v1.js +2 -0
- package/lib/services/webhosting_free_domain_v1.js.map +1 -0
- package/lib/services/webhosting_ftp_account_v1.d.ts +79 -0
- package/lib/services/webhosting_ftp_account_v1.d.ts.map +1 -0
- package/lib/services/webhosting_ftp_account_v1.js +2 -0
- package/lib/services/webhosting_ftp_account_v1.js.map +1 -0
- package/lib/services/webhosting_hosting_v1.d.ts +502 -0
- package/lib/services/webhosting_hosting_v1.d.ts.map +1 -0
- package/lib/services/webhosting_hosting_v1.js +27 -0
- package/lib/services/webhosting_hosting_v1.js.map +1 -0
- package/lib/services/webhosting_mail_account_v1.d.ts +84 -0
- package/lib/services/webhosting_mail_account_v1.d.ts.map +1 -0
- package/lib/services/webhosting_mail_account_v1.js +2 -0
- package/lib/services/webhosting_mail_account_v1.js.map +1 -0
- package/lib/services/webhosting_offer_v1.d.ts +122 -0
- package/lib/services/webhosting_offer_v1.d.ts.map +1 -0
- package/lib/services/webhosting_offer_v1.js +2 -0
- package/lib/services/webhosting_offer_v1.js.map +1 -0
- package/lib/services/webhosting_website_v1.d.ts +75 -0
- package/lib/services/webhosting_website_v1.d.ts.map +1 -0
- package/lib/services/webhosting_website_v1.js +2 -0
- package/lib/services/webhosting_website_v1.js.map +1 -0
- package/lib/services.lazy/account_contract_v3.js +1 -0
- package/lib/services.lazy/account_iso_code_v3.js +1 -0
- package/lib/services.lazy/account_organization_v3.js +1 -0
- package/lib/services.lazy/account_project_v3.js +1 -0
- package/lib/services.lazy/account_unauthenticated_user_v3.js +3 -0
- package/lib/services.lazy/account_unauthenticated_v3.js +1 -0
- package/lib/services.lazy/account_user_v3.js +3 -0
- package/lib/services.lazy/annotations_v1.js +1 -0
- package/lib/services.lazy/baremetal_private_network_v1.js +1 -0
- package/lib/services.lazy/baremetal_private_network_v3.js +1 -0
- package/lib/services.lazy/baremetal_v1.js +3 -0
- package/lib/services.lazy/billing_electronic_billing_v2.js +1 -0
- package/lib/services.lazy/billing_v2.js +1 -0
- package/lib/services.lazy/block_v1.js +3 -0
- package/lib/services.lazy/cockpit_global_v1.js +1 -0
- package/lib/services.lazy/cockpit_regional_v1.js +3 -0
- package/lib/services.lazy/containers_v1.js +3 -0
- package/lib/services.lazy/dedibox_billing_v1.js +1 -0
- package/lib/services.lazy/dedibox_ipv6_block_v1.js +1 -0
- package/lib/services.lazy/dedibox_rpn_san_v1.js +1 -0
- package/lib/services.lazy/dedibox_rpn_v1.js +1 -0
- package/lib/services.lazy/dedibox_rpn_v1_v1.js +3 -0
- package/lib/services.lazy/dedibox_rpn_v2_v1.js +3 -0
- package/lib/services.lazy/dedibox_v1.js +3 -0
- package/lib/services.lazy/generative_apis_openai_v1.js +3 -0
- package/lib/services.lazy/generative_apis_v1.js +1 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/inference_v1.js +3 -0
- package/lib/services.lazy/instance_v1.js +3 -0
- package/lib/services.lazy/iot_v1.js +3 -0
- package/lib/services.lazy/ipam_v1.js +1 -0
- package/lib/services.lazy/k8s_v1.js +3 -0
- package/lib/services.lazy/lb_zoned_v1.js +3 -0
- package/lib/services.lazy/marketplace_console_v2.js +1 -0
- package/lib/services.lazy/marketplace_v2.js +1 -0
- package/lib/services.lazy/mongodb_v1.js +3 -0
- package/lib/services.lazy/partner_v1.js +1 -0
- package/lib/services.lazy/rdb_encryption_v1.js +1 -0
- package/lib/services.lazy/rdb_v1.js +3 -0
- package/lib/services.lazy/redis_v1.js +3 -0
- package/lib/services.lazy/registry_v1.js +1 -0
- package/lib/services.lazy/reseller_v1.js +1 -0
- package/lib/services.lazy/vpc_gw_v2.js +3 -0
- package/lib/services.lazy/vpc_private_network_with_nics_v2.js +1 -0
- package/lib/services.lazy/vpc_routes_with_nexthop_v2.js +1 -0
- package/lib/services.lazy/vpc_v2.js +3 -0
- package/lib/services.lazy/webhosting_backup_v1.js +1 -0
- package/lib/services.lazy/webhosting_control_panel_v1.js +1 -0
- package/lib/services.lazy/webhosting_database_v1.js +1 -0
- package/lib/services.lazy/webhosting_dedibox_v1.js +1 -0
- package/lib/services.lazy/webhosting_dns_v1.js +1 -0
- package/lib/services.lazy/webhosting_free_domain_v1.js +1 -0
- package/lib/services.lazy/webhosting_ftp_account_v1.js +1 -0
- package/lib/services.lazy/webhosting_hosting_v1.js +3 -0
- package/lib/services.lazy/webhosting_mail_account_v1.js +1 -0
- package/lib/services.lazy/webhosting_offer_v1.js +1 -0
- package/lib/services.lazy/webhosting_website_v1.js +1 -0
- package/lib/traits.d.ts +25 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +1 -0
- package/lib/unstable-services/apple_silicon_private_network_v1alpha1.d.ts +119 -0
- package/lib/unstable-services/apple_silicon_private_network_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/apple_silicon_private_network_v1alpha1.js +2 -0
- package/lib/unstable-services/apple_silicon_private_network_v1alpha1.js.map +1 -0
- package/lib/unstable-services/apple_silicon_v1alpha1.d.ts +569 -0
- package/lib/unstable-services/apple_silicon_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/apple_silicon_v1alpha1.js +38 -0
- package/lib/unstable-services/apple_silicon_v1alpha1.js.map +1 -0
- package/lib/unstable-services/audit_trail_v1alpha1.d.ts +1082 -0
- package/lib/unstable-services/audit_trail_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/audit_trail_v1alpha1.js +47 -0
- package/lib/unstable-services/audit_trail_v1alpha1.js.map +1 -0
- package/lib/unstable-services/autoscaling_v1alpha2.d.ts +368 -0
- package/lib/unstable-services/autoscaling_v1alpha2.d.ts.map +1 -0
- package/lib/unstable-services/autoscaling_v1alpha2.js +2 -0
- package/lib/unstable-services/autoscaling_v1alpha2.js.map +1 -0
- package/lib/unstable-services/billing_fin_ops_v2beta1.d.ts +78 -0
- package/lib/unstable-services/billing_fin_ops_v2beta1.d.ts.map +1 -0
- package/lib/unstable-services/billing_fin_ops_v2beta1.js +2 -0
- package/lib/unstable-services/billing_fin_ops_v2beta1.js.map +1 -0
- package/lib/unstable-services/billing_v2beta1.d.ts +411 -0
- package/lib/unstable-services/billing_v2beta1.d.ts.map +1 -0
- package/lib/unstable-services/billing_v2beta1.js +25 -0
- package/lib/unstable-services/billing_v2beta1.js.map +1 -0
- package/lib/unstable-services/block_v1alpha1.d.ts +372 -0
- package/lib/unstable-services/block_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/block_v1alpha1.js +27 -0
- package/lib/unstable-services/block_v1alpha1.js.map +1 -0
- package/lib/unstable-services/data_orchestrator_v1alpha2.d.ts +440 -0
- package/lib/unstable-services/data_orchestrator_v1alpha2.d.ts.map +1 -0
- package/lib/unstable-services/data_orchestrator_v1alpha2.js +27 -0
- package/lib/unstable-services/data_orchestrator_v1alpha2.js.map +1 -0
- package/lib/unstable-services/datalab_v1beta1.d.ts +322 -0
- package/lib/unstable-services/datalab_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/datalab_v1beta1.js +2 -0
- package/lib/unstable-services/datalab_v1beta1.js.map +1 -0
- package/lib/unstable-services/dataviz_v1alpha1.d.ts +456 -0
- package/lib/unstable-services/dataviz_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/dataviz_v1alpha1.js +34 -0
- package/lib/unstable-services/dataviz_v1alpha1.js.map +1 -0
- package/lib/unstable-services/datawarehouse_v1beta1.d.ts +492 -0
- package/lib/unstable-services/datawarehouse_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/datawarehouse_v1beta1.js +34 -0
- package/lib/unstable-services/datawarehouse_v1beta1.js.map +1 -0
- package/lib/unstable-services/domain_registrar_v2beta1.d.ts +1087 -0
- package/lib/unstable-services/domain_registrar_v2beta1.d.ts.map +1 -0
- package/lib/unstable-services/domain_registrar_v2beta1.js +50 -0
- package/lib/unstable-services/domain_registrar_v2beta1.js.map +1 -0
- package/lib/unstable-services/domain_suggestion_v2beta1.d.ts +19 -0
- package/lib/unstable-services/domain_suggestion_v2beta1.d.ts.map +1 -0
- package/lib/unstable-services/domain_suggestion_v2beta1.js +2 -0
- package/lib/unstable-services/domain_suggestion_v2beta1.js.map +1 -0
- package/lib/unstable-services/domain_v2beta1.d.ts +520 -0
- package/lib/unstable-services/domain_v2beta1.d.ts.map +1 -0
- package/lib/unstable-services/domain_v2beta1.js +44 -0
- package/lib/unstable-services/domain_v2beta1.js.map +1 -0
- package/lib/unstable-services/edge_services_v1beta1.d.ts +1153 -0
- package/lib/unstable-services/edge_services_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/edge_services_v1beta1.js +81 -0
- package/lib/unstable-services/edge_services_v1beta1.js.map +1 -0
- package/lib/unstable-services/environmental_footprint_user_v1alpha1.d.ts +149 -0
- package/lib/unstable-services/environmental_footprint_user_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/environmental_footprint_user_v1alpha1.js +2 -0
- package/lib/unstable-services/environmental_footprint_user_v1alpha1.js.map +1 -0
- package/lib/unstable-services/file_v1alpha1.d.ts +350 -0
- package/lib/unstable-services/file_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/file_v1alpha1.js +24 -0
- package/lib/unstable-services/file_v1alpha1.js.map +1 -0
- package/lib/unstable-services/flexible_ip_v1alpha1.d.ts +241 -0
- package/lib/unstable-services/flexible_ip_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/flexible_ip_v1alpha1.js +2 -0
- package/lib/unstable-services/flexible_ip_v1alpha1.js.map +1 -0
- package/lib/unstable-services/functions_v1beta1.d.ts +852 -0
- package/lib/unstable-services/functions_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/functions_v1beta1.js +49 -0
- package/lib/unstable-services/functions_v1beta1.js.map +1 -0
- package/lib/unstable-services/iam_unauthenticated_v1alpha1.d.ts +257 -0
- package/lib/unstable-services/iam_unauthenticated_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/iam_unauthenticated_v1alpha1.js +2 -0
- package/lib/unstable-services/iam_unauthenticated_v1alpha1.js.map +1 -0
- package/lib/unstable-services/iam_v1alpha1.d.ts +1506 -0
- package/lib/unstable-services/iam_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/iam_v1alpha1.js +105 -0
- package/lib/unstable-services/iam_v1alpha1.js.map +1 -0
- package/lib/unstable-services/index.d.ts +44 -0
- package/lib/unstable-services/index.d.ts.map +1 -0
- package/lib/unstable-services/index.js +43 -0
- package/lib/unstable-services/instance_v2alpha1.d.ts +1745 -0
- package/lib/unstable-services/instance_v2alpha1.d.ts.map +1 -0
- package/lib/unstable-services/instance_v2alpha1.js +81 -0
- package/lib/unstable-services/instance_v2alpha1.js.map +1 -0
- package/lib/unstable-services/instance_volume_v2alpha1.d.ts +333 -0
- package/lib/unstable-services/instance_volume_v2alpha1.d.ts.map +1 -0
- package/lib/unstable-services/instance_volume_v2alpha1.js +26 -0
- package/lib/unstable-services/instance_volume_v2alpha1.js.map +1 -0
- package/lib/unstable-services/interlink_v1beta1.d.ts +636 -0
- package/lib/unstable-services/interlink_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/interlink_v1beta1.js +39 -0
- package/lib/unstable-services/interlink_v1beta1.js.map +1 -0
- package/lib/unstable-services/kafka_v1alpha1.d.ts +451 -0
- package/lib/unstable-services/kafka_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/kafka_v1alpha1.js +27 -0
- package/lib/unstable-services/kafka_v1alpha1.js.map +1 -0
- package/lib/unstable-services/key_manager_v1alpha1.d.ts +515 -0
- package/lib/unstable-services/key_manager_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/key_manager_v1alpha1.js +36 -0
- package/lib/unstable-services/key_manager_v1alpha1.js.map +1 -0
- package/lib/unstable-services/mailbox_v1alpha1.d.ts +438 -0
- package/lib/unstable-services/mailbox_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/mailbox_v1alpha1.js +39 -0
- package/lib/unstable-services/mailbox_v1alpha1.js.map +1 -0
- package/lib/unstable-services/messageq_v1alpha1.d.ts +420 -0
- package/lib/unstable-services/messageq_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/messageq_v1alpha1.js +29 -0
- package/lib/unstable-services/messageq_v1alpha1.js.map +1 -0
- package/lib/unstable-services/mnq_console_v1beta1.d.ts +32 -0
- package/lib/unstable-services/mnq_console_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/mnq_console_v1beta1.js +2 -0
- package/lib/unstable-services/mnq_console_v1beta1.js.map +1 -0
- package/lib/unstable-services/mnq_nats_v1beta1.d.ts +177 -0
- package/lib/unstable-services/mnq_nats_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/mnq_nats_v1beta1.js +2 -0
- package/lib/unstable-services/mnq_nats_v1beta1.js.map +1 -0
- package/lib/unstable-services/mnq_sns_v1beta1.d.ts +155 -0
- package/lib/unstable-services/mnq_sns_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/mnq_sns_v1beta1.js +2 -0
- package/lib/unstable-services/mnq_sns_v1beta1.js.map +1 -0
- package/lib/unstable-services/mnq_sqs_v1beta1.d.ts +155 -0
- package/lib/unstable-services/mnq_sqs_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/mnq_sqs_v1beta1.js +2 -0
- package/lib/unstable-services/mnq_sqs_v1beta1.js.map +1 -0
- package/lib/unstable-services/mongodb_v1alpha1.d.ts +604 -0
- package/lib/unstable-services/mongodb_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/mongodb_v1alpha1.js +37 -0
- package/lib/unstable-services/mongodb_v1alpha1.js.map +1 -0
- package/lib/unstable-services/product_catalog_public_catalog_v2alpha1.d.ts +477 -0
- package/lib/unstable-services/product_catalog_public_catalog_v2alpha1.d.ts.map +1 -0
- package/lib/unstable-services/product_catalog_public_catalog_v2alpha1.js +2 -0
- package/lib/unstable-services/product_catalog_public_catalog_v2alpha1.js.map +1 -0
- package/lib/unstable-services/qaas_v1alpha1.d.ts +764 -0
- package/lib/unstable-services/qaas_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/qaas_v1alpha1.js +51 -0
- package/lib/unstable-services/qaas_v1alpha1.js.map +1 -0
- package/lib/unstable-services/s2s_vpn_v1alpha1.d.ts +794 -0
- package/lib/unstable-services/s2s_vpn_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/s2s_vpn_v1alpha1.js +45 -0
- package/lib/unstable-services/s2s_vpn_v1alpha1.js.map +1 -0
- package/lib/unstable-services/search_v1alpha1.d.ts +120 -0
- package/lib/unstable-services/search_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/search_v1alpha1.js +2 -0
- package/lib/unstable-services/search_v1alpha1.js.map +1 -0
- package/lib/unstable-services/searchdb_v1alpha1.d.ts +424 -0
- package/lib/unstable-services/searchdb_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/searchdb_v1alpha1.js +29 -0
- package/lib/unstable-services/searchdb_v1alpha1.js.map +1 -0
- package/lib/unstable-services/secret_manager_v1beta1.d.ts +407 -0
- package/lib/unstable-services/secret_manager_v1beta1.d.ts.map +1 -0
- package/lib/unstable-services/secret_manager_v1beta1.js +32 -0
- package/lib/unstable-services/secret_manager_v1beta1.js.map +1 -0
- package/lib/unstable-services/serverless_jobs_v1alpha1.d.ts +331 -0
- package/lib/unstable-services/serverless_jobs_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/serverless_jobs_v1alpha1.js +28 -0
- package/lib/unstable-services/serverless_jobs_v1alpha1.js.map +1 -0
- package/lib/unstable-services/serverless_jobs_v1alpha2.d.ts +546 -0
- package/lib/unstable-services/serverless_jobs_v1alpha2.d.ts.map +1 -0
- package/lib/unstable-services/serverless_jobs_v1alpha2.js +35 -0
- package/lib/unstable-services/serverless_jobs_v1alpha2.js.map +1 -0
- package/lib/unstable-services/serverless_sqldb_v1alpha1.d.ts +239 -0
- package/lib/unstable-services/serverless_sqldb_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/serverless_sqldb_v1alpha1.js +2 -0
- package/lib/unstable-services/serverless_sqldb_v1alpha1.js.map +1 -0
- package/lib/unstable-services/transactional_email_v1alpha1.d.ts +936 -0
- package/lib/unstable-services/transactional_email_v1alpha1.d.ts.map +1 -0
- package/lib/unstable-services/transactional_email_v1alpha1.js +46 -0
- package/lib/unstable-services/transactional_email_v1alpha1.js.map +1 -0
- package/lib/unstable-services.lazy/apple_silicon_private_network_v1alpha1.js +1 -0
- package/lib/unstable-services.lazy/apple_silicon_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/audit_trail_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/autoscaling_v1alpha2.js +1 -0
- package/lib/unstable-services.lazy/billing_fin_ops_v2beta1.js +1 -0
- package/lib/unstable-services.lazy/billing_v2beta1.js +3 -0
- package/lib/unstable-services.lazy/block_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/data_orchestrator_v1alpha2.js +3 -0
- package/lib/unstable-services.lazy/datalab_v1beta1.js +1 -0
- package/lib/unstable-services.lazy/dataviz_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/datawarehouse_v1beta1.js +3 -0
- package/lib/unstable-services.lazy/domain_registrar_v2beta1.js +3 -0
- package/lib/unstable-services.lazy/domain_suggestion_v2beta1.js +1 -0
- package/lib/unstable-services.lazy/domain_v2beta1.js +3 -0
- package/lib/unstable-services.lazy/edge_services_v1beta1.js +3 -0
- package/lib/unstable-services.lazy/environmental_footprint_user_v1alpha1.js +1 -0
- package/lib/unstable-services.lazy/file_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/flexible_ip_v1alpha1.js +1 -0
- package/lib/unstable-services.lazy/functions_v1beta1.js +3 -0
- package/lib/unstable-services.lazy/iam_unauthenticated_v1alpha1.js +1 -0
- package/lib/unstable-services.lazy/iam_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/index.js +3 -0
- package/lib/unstable-services.lazy/instance_v2alpha1.js +3 -0
- package/lib/unstable-services.lazy/instance_volume_v2alpha1.js +3 -0
- package/lib/unstable-services.lazy/interlink_v1beta1.js +3 -0
- package/lib/unstable-services.lazy/kafka_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/key_manager_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/mailbox_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/messageq_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/mnq_console_v1beta1.js +1 -0
- package/lib/unstable-services.lazy/mnq_nats_v1beta1.js +1 -0
- package/lib/unstable-services.lazy/mnq_sns_v1beta1.js +1 -0
- package/lib/unstable-services.lazy/mnq_sqs_v1beta1.js +1 -0
- package/lib/unstable-services.lazy/mongodb_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/product_catalog_public_catalog_v2alpha1.js +1 -0
- package/lib/unstable-services.lazy/qaas_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/s2s_vpn_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/search_v1alpha1.js +1 -0
- package/lib/unstable-services.lazy/searchdb_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/secret_manager_v1beta1.js +3 -0
- package/lib/unstable-services.lazy/serverless_jobs_v1alpha1.js +3 -0
- package/lib/unstable-services.lazy/serverless_jobs_v1alpha2.js +3 -0
- package/lib/unstable-services.lazy/serverless_sqldb_v1alpha1.js +1 -0
- package/lib/unstable-services.lazy/transactional_email_v1alpha1.js +3 -0
- package/package.json +94 -3
- package/src/credentials.ts +104 -0
- package/src/errors.ts +307 -0
- package/src/index.ts +52 -0
- package/src/pagination.ts +65 -0
- package/src/protocol.ts +496 -0
- package/src/retry.ts +47 -0
- package/src/services/account_contract_v3.ts +441 -0
- package/src/services/account_iso_code_v3.ts +165 -0
- package/src/services/account_organization_v3.ts +946 -0
- package/src/services/account_project_v3.ts +530 -0
- package/src/services/account_unauthenticated_user_v3.ts +1445 -0
- package/src/services/account_unauthenticated_v3.ts +92 -0
- package/src/services/account_user_v3.ts +1657 -0
- package/src/services/annotations_v1.ts +897 -0
- package/src/services/baremetal_private_network_v1.ts +327 -0
- package/src/services/baremetal_private_network_v3.ts +376 -0
- package/src/services/baremetal_v1.ts +3072 -0
- package/src/services/billing_electronic_billing_v2.ts +323 -0
- package/src/services/billing_v2.ts +662 -0
- package/src/services/block_v1.ts +1282 -0
- package/src/services/cockpit_global_v1.ts +282 -0
- package/src/services/cockpit_regional_v1.ts +2177 -0
- package/src/services/containers_v1.ts +2110 -0
- package/src/services/dedibox_billing_v1.ts +621 -0
- package/src/services/dedibox_ipv6_block_v1.ts +468 -0
- package/src/services/dedibox_rpn_san_v1.ts +1185 -0
- package/src/services/dedibox_rpn_v1.ts +207 -0
- package/src/services/dedibox_rpn_v1_v1.ts +1763 -0
- package/src/services/dedibox_rpn_v2_v1.ts +1654 -0
- package/src/services/dedibox_v1.ts +3765 -0
- package/src/services/generative_apis_openai_v1.ts +1692 -0
- package/src/services/generative_apis_v1.ts +251 -0
- package/src/services/index.ts +57 -0
- package/src/services/inference_v1.ts +1353 -0
- package/src/services/instance_v1.ts +6611 -0
- package/src/services/iot_v1.ts +2419 -0
- package/src/services/ipam_v1.ts +716 -0
- package/src/services/k8s_v1.ts +3108 -0
- package/src/services/lb_zoned_v1.ts +4533 -0
- package/src/services/marketplace_console_v2.ts +198 -0
- package/src/services/marketplace_v2.ts +625 -0
- package/src/services/mongodb_v1.ts +2104 -0
- package/src/services/partner_v1.ts +462 -0
- package/src/services/rdb_encryption_v1.ts +83 -0
- package/src/services/rdb_v1.ts +4211 -0
- package/src/services/redis_v1.ts +1918 -0
- package/src/services/registry_v1.ts +863 -0
- package/src/services/reseller_v1.ts +258 -0
- package/src/services/vpc_gw_v2.ts +2130 -0
- package/src/services/vpc_private_network_with_nics_v2.ts +311 -0
- package/src/services/vpc_routes_with_nexthop_v2.ts +226 -0
- package/src/services/vpc_v2.ts +2533 -0
- package/src/services/webhosting_backup_v1.ts +578 -0
- package/src/services/webhosting_control_panel_v1.ts +130 -0
- package/src/services/webhosting_database_v1.ts +682 -0
- package/src/services/webhosting_dedibox_v1.ts +480 -0
- package/src/services/webhosting_dns_v1.ts +471 -0
- package/src/services/webhosting_free_domain_v1.ts +190 -0
- package/src/services/webhosting_ftp_account_v1.ts +280 -0
- package/src/services/webhosting_hosting_v1.ts +1309 -0
- package/src/services/webhosting_mail_account_v1.ts +291 -0
- package/src/services/webhosting_offer_v1.ts +289 -0
- package/src/services/webhosting_website_v1.ts +274 -0
- package/src/traits.ts +63 -0
- package/src/unstable-services/apple_silicon_private_network_v1alpha1.ts +395 -0
- package/src/unstable-services/apple_silicon_v1alpha1.ts +1685 -0
- package/src/unstable-services/audit_trail_v1alpha1.ts +3220 -0
- package/src/unstable-services/autoscaling_v1alpha2.ts +1103 -0
- package/src/unstable-services/billing_fin_ops_v2beta1.ts +195 -0
- package/src/unstable-services/billing_v2beta1.ts +1203 -0
- package/src/unstable-services/block_v1alpha1.ts +1239 -0
- package/src/unstable-services/data_orchestrator_v1alpha2.ts +1230 -0
- package/src/unstable-services/datalab_v1beta1.ts +852 -0
- package/src/unstable-services/dataviz_v1alpha1.ts +1478 -0
- package/src/unstable-services/datawarehouse_v1beta1.ts +1504 -0
- package/src/unstable-services/domain_registrar_v2beta1.ts +2979 -0
- package/src/unstable-services/domain_suggestion_v2beta1.ts +86 -0
- package/src/unstable-services/domain_v2beta1.ts +1794 -0
- package/src/unstable-services/edge_services_v1beta1.ts +3724 -0
- package/src/unstable-services/environmental_footprint_user_v1alpha1.ts +429 -0
- package/src/unstable-services/file_v1alpha1.ts +1016 -0
- package/src/unstable-services/flexible_ip_v1alpha1.ts +804 -0
- package/src/unstable-services/functions_v1beta1.ts +2410 -0
- package/src/unstable-services/iam_unauthenticated_v1alpha1.ts +863 -0
- package/src/unstable-services/iam_v1alpha1.ts +4919 -0
- package/src/unstable-services/index.ts +44 -0
- package/src/unstable-services/instance_v2alpha1.ts +5377 -0
- package/src/unstable-services/instance_volume_v2alpha1.ts +1111 -0
- package/src/unstable-services/interlink_v1beta1.ts +1791 -0
- package/src/unstable-services/kafka_v1alpha1.ts +1275 -0
- package/src/unstable-services/key_manager_v1alpha1.ts +1618 -0
- package/src/unstable-services/mailbox_v1alpha1.ts +1561 -0
- package/src/unstable-services/messageq_v1alpha1.ts +1266 -0
- package/src/unstable-services/mnq_console_v1beta1.ts +111 -0
- package/src/unstable-services/mnq_nats_v1beta1.ts +608 -0
- package/src/unstable-services/mnq_sns_v1beta1.ts +523 -0
- package/src/unstable-services/mnq_sqs_v1beta1.ts +523 -0
- package/src/unstable-services/mongodb_v1alpha1.ts +1789 -0
- package/src/unstable-services/product_catalog_public_catalog_v2alpha1.ts +1109 -0
- package/src/unstable-services/qaas_v1alpha1.ts +2404 -0
- package/src/unstable-services/s2s_vpn_v1alpha1.ts +2173 -0
- package/src/unstable-services/search_v1alpha1.ts +349 -0
- package/src/unstable-services/searchdb_v1alpha1.ts +1273 -0
- package/src/unstable-services/secret_manager_v1beta1.ts +1255 -0
- package/src/unstable-services/serverless_jobs_v1alpha1.ts +1017 -0
- package/src/unstable-services/serverless_jobs_v1alpha2.ts +1516 -0
- package/src/unstable-services/serverless_sqldb_v1alpha1.ts +747 -0
- package/src/unstable-services/transactional_email_v1alpha1.ts +2495 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
2
|
+
/**
|
|
3
|
+
* Scaleway credentials -- hand-written.
|
|
4
|
+
*
|
|
5
|
+
* The `Credentials` service resolves {@link Config} per request; the
|
|
6
|
+
* protocol sends the secret key as `X-Auth-Token` (and as
|
|
7
|
+
* `Authorization: Bearer` to Generative APIs on `api.scaleway.ai`, which
|
|
8
|
+
* speaks the OpenAI convention) and fills an operation's `{region}` /
|
|
9
|
+
* `{zone}` path segment from the defaults here when the caller leaves it
|
|
10
|
+
* out.
|
|
11
|
+
*
|
|
12
|
+
* {@link CredentialsFromEnv} reads the same `SCW_*` variables as the
|
|
13
|
+
* official Go/JS/Python SDKs, the `scw` CLI and the Terraform provider.
|
|
14
|
+
* The `~/.config/scw/config.yaml` profile file is not read: export the
|
|
15
|
+
* profile's values instead (`scw config dump`).
|
|
16
|
+
*/
|
|
17
|
+
import * as EffectConfig from "effect/Config";
|
|
18
|
+
import * as Context from "effect/Context";
|
|
19
|
+
import * as Effect from "effect/Effect";
|
|
20
|
+
import * as Layer from "effect/Layer";
|
|
21
|
+
import * as Option from "effect/Option";
|
|
22
|
+
import * as Redacted from "effect/Redacted";
|
|
23
|
+
|
|
24
|
+
/** Scaleway's API host -- what `SCW_API_URL` overrides. */
|
|
25
|
+
export const DEFAULT_API_URL = "https://api.scaleway.com";
|
|
26
|
+
/** Region used when neither the call nor `SCW_DEFAULT_REGION` names one (the CLI's and Terraform's default). */
|
|
27
|
+
export const DEFAULT_REGION = "fr-par";
|
|
28
|
+
/** Zone used when neither the call nor `SCW_DEFAULT_ZONE` names one (the CLI's and Terraform's default). */
|
|
29
|
+
export const DEFAULT_ZONE = "fr-par-1";
|
|
30
|
+
|
|
31
|
+
export interface Config {
|
|
32
|
+
/** API secret key (a UUID), sent as `X-Auth-Token`. */
|
|
33
|
+
readonly secretKey: Redacted.Redacted<string>;
|
|
34
|
+
/** Region filled into `{region}` when a call omits `region`. */
|
|
35
|
+
readonly region: string;
|
|
36
|
+
/** Zone filled into `{zone}` when a call omits `zone`. */
|
|
37
|
+
readonly zone: string;
|
|
38
|
+
/** Default Organization ID (`SCW_DEFAULT_ORGANIZATION_ID`), for callers building requests. */
|
|
39
|
+
readonly organizationId?: string;
|
|
40
|
+
/** Default Project ID (`SCW_DEFAULT_PROJECT_ID`), for callers building requests. */
|
|
41
|
+
readonly projectId?: string;
|
|
42
|
+
/** Replaces {@link DEFAULT_API_URL} for every `api.scaleway.com` operation. */
|
|
43
|
+
readonly apiUrl?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
|
|
47
|
+
"ScalewayCredentials",
|
|
48
|
+
) {}
|
|
49
|
+
|
|
50
|
+
const optional = (name: string) => EffectConfig.String(name).pipe(EffectConfig.option);
|
|
51
|
+
|
|
52
|
+
const envConfig = EffectConfig.all({
|
|
53
|
+
secretKey: EffectConfig.Redacted("SCW_SECRET_KEY"),
|
|
54
|
+
region: EffectConfig.String("SCW_DEFAULT_REGION").pipe(EffectConfig.withDefault(DEFAULT_REGION)),
|
|
55
|
+
zone: EffectConfig.String("SCW_DEFAULT_ZONE").pipe(EffectConfig.withDefault(DEFAULT_ZONE)),
|
|
56
|
+
organizationId: optional("SCW_DEFAULT_ORGANIZATION_ID"),
|
|
57
|
+
projectId: optional("SCW_DEFAULT_PROJECT_ID"),
|
|
58
|
+
apiUrl: optional("SCW_API_URL"),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Its configuration is read and checked once, when the layer is built: a
|
|
63
|
+
* problem there fails the layer with `ConfigError`.
|
|
64
|
+
*/
|
|
65
|
+
export const CredentialsFromEnv = Layer.effect(
|
|
66
|
+
Credentials,
|
|
67
|
+
/*@__PURE__*/ Effect.map(
|
|
68
|
+
envConfig.pipe(
|
|
69
|
+
Effect.mapError(
|
|
70
|
+
() =>
|
|
71
|
+
new ConfigError({
|
|
72
|
+
message: "SCW_SECRET_KEY environment variable is required",
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
75
|
+
Effect.map((env): Config => ({
|
|
76
|
+
secretKey: env.secretKey,
|
|
77
|
+
region: env.region,
|
|
78
|
+
zone: env.zone,
|
|
79
|
+
organizationId: Option.getOrUndefined(env.organizationId),
|
|
80
|
+
projectId: Option.getOrUndefined(env.projectId),
|
|
81
|
+
apiUrl: Option.getOrUndefined(env.apiUrl),
|
|
82
|
+
})),
|
|
83
|
+
),
|
|
84
|
+
(config) => Effect.succeed(config),
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
/** Convenience layer from a redacted secret key and optional defaults. */
|
|
89
|
+
export const credentials = (config: {
|
|
90
|
+
readonly secretKey: Redacted.Redacted<string>;
|
|
91
|
+
readonly region?: string;
|
|
92
|
+
readonly zone?: string;
|
|
93
|
+
readonly organizationId?: string;
|
|
94
|
+
readonly projectId?: string;
|
|
95
|
+
readonly apiUrl?: string;
|
|
96
|
+
}): Layer.Layer<Credentials> =>
|
|
97
|
+
Layer.succeed(
|
|
98
|
+
Credentials,
|
|
99
|
+
Effect.succeed({
|
|
100
|
+
...config,
|
|
101
|
+
region: config.region ?? DEFAULT_REGION,
|
|
102
|
+
zone: config.zone ?? DEFAULT_ZONE,
|
|
103
|
+
}),
|
|
104
|
+
);
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scaleway error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the common HTTP errors from core and adds Scaleway's own.
|
|
5
|
+
* Every Scaleway API answers a failure with one JSON envelope --
|
|
6
|
+
* `{ "type": "...", "message": "...", ... }` -- whose `type` names the
|
|
7
|
+
* failure and decides which fields come with it (`resource` /
|
|
8
|
+
* `resource_id` for `not_found`, `current_state` for `transient_state`,
|
|
9
|
+
* `details[]` for `invalid_arguments` / `quotas_exceeded` /
|
|
10
|
+
* `permissions_denied`, ...). The protocol dispatches on `type` first, the
|
|
11
|
+
* same table the official SDKs use (scaleway-sdk-js
|
|
12
|
+
* `packages/client/src/scw/errors/error-parser.ts`, scaleway-sdk-go
|
|
13
|
+
* `scw/errors.go`), then on the HTTP status, so a `409` is a
|
|
14
|
+
* {@link TransientStateError} or an {@link AlreadyExistsError} rather than
|
|
15
|
+
* a bare `Conflict`.
|
|
16
|
+
*
|
|
17
|
+
* The specs declare no error responses at all, so these classes ride every
|
|
18
|
+
* operation's `ScalewayOpError` instead of per-operation error lists.
|
|
19
|
+
*/
|
|
20
|
+
export {
|
|
21
|
+
BadGateway,
|
|
22
|
+
BadRequest,
|
|
23
|
+
Conflict,
|
|
24
|
+
ConfigError,
|
|
25
|
+
Forbidden,
|
|
26
|
+
GatewayTimeout,
|
|
27
|
+
InternalServerError,
|
|
28
|
+
Locked,
|
|
29
|
+
NotFound,
|
|
30
|
+
ServiceUnavailable,
|
|
31
|
+
TooManyRequests,
|
|
32
|
+
Unauthorized,
|
|
33
|
+
UnprocessableEntity,
|
|
34
|
+
HTTP_STATUS_MAP,
|
|
35
|
+
DEFAULT_ERRORS,
|
|
36
|
+
API_ERRORS,
|
|
37
|
+
} from "@distilled.cloud/core/errors";
|
|
38
|
+
import * as Category from "@distilled.cloud/core/category";
|
|
39
|
+
import type {
|
|
40
|
+
BadRequest as CoreBadRequest,
|
|
41
|
+
Conflict as CoreConflict,
|
|
42
|
+
DefaultErrors as CoreDefaultErrors,
|
|
43
|
+
Forbidden as CoreForbidden,
|
|
44
|
+
Locked as CoreLocked,
|
|
45
|
+
NotFound as CoreNotFound,
|
|
46
|
+
UnprocessableEntity as CoreUnprocessableEntity,
|
|
47
|
+
} from "@distilled.cloud/core/errors";
|
|
48
|
+
import { API_ERRORS } from "@distilled.cloud/core/errors";
|
|
49
|
+
import * as Schema from "effect/Schema";
|
|
50
|
+
|
|
51
|
+
/** One rejected argument of an `invalid_arguments` failure. */
|
|
52
|
+
export const InvalidArgumentDetail = Schema.Struct({
|
|
53
|
+
argument_name: Schema.String,
|
|
54
|
+
/** `required`, `format` or `constraint`. */
|
|
55
|
+
reason: Schema.String,
|
|
56
|
+
help_message: Schema.optional(Schema.String),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/** One exceeded quota of a `quotas_exceeded` failure. */
|
|
60
|
+
export const QuotaDetail = Schema.Struct({
|
|
61
|
+
resource: Schema.String,
|
|
62
|
+
quota: Schema.Number,
|
|
63
|
+
current: Schema.Number,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/** One missing permission of a `permissions_denied` failure. */
|
|
67
|
+
export const PermissionDetail = Schema.Struct({
|
|
68
|
+
resource: Schema.String,
|
|
69
|
+
action: Schema.String,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* `invalid_arguments` (400) -- one or more request fields were missing,
|
|
74
|
+
* malformed or out of range; `details` names each one. Also raised for the
|
|
75
|
+
* legacy `invalid_request_error` envelope (Instance v1) when it lists
|
|
76
|
+
* `fields`.
|
|
77
|
+
*/
|
|
78
|
+
export class InvalidArgumentsError extends Schema.TaggedError<InvalidArgumentsError>()(
|
|
79
|
+
"InvalidArgumentsError",
|
|
80
|
+
{
|
|
81
|
+
message: Schema.String,
|
|
82
|
+
details: Schema.Array(InvalidArgumentDetail),
|
|
83
|
+
body: Schema.Unknown,
|
|
84
|
+
},
|
|
85
|
+
).pipe(Category.withBadRequestError) {}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* `denied_authentication` (401) -- the secret key is missing, unknown,
|
|
89
|
+
* expired or the wrong kind for this API. `method` is the authentication
|
|
90
|
+
* method tried, `reason` why it failed (`invalid_argument`, `not_found`,
|
|
91
|
+
* `expired`, ...).
|
|
92
|
+
*/
|
|
93
|
+
export class DeniedAuthenticationError extends Schema.TaggedError<DeniedAuthenticationError>()(
|
|
94
|
+
"DeniedAuthenticationError",
|
|
95
|
+
{
|
|
96
|
+
message: Schema.String,
|
|
97
|
+
method: Schema.optional(Schema.String),
|
|
98
|
+
reason: Schema.optional(Schema.String),
|
|
99
|
+
body: Schema.Unknown,
|
|
100
|
+
},
|
|
101
|
+
).pipe(Category.withAuthError) {}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* `permissions_denied` (403) -- the key authenticated, but its IAM policy
|
|
105
|
+
* does not grant the listed actions.
|
|
106
|
+
*/
|
|
107
|
+
export class PermissionsDeniedError extends Schema.TaggedError<PermissionsDeniedError>()(
|
|
108
|
+
"PermissionsDeniedError",
|
|
109
|
+
{
|
|
110
|
+
message: Schema.String,
|
|
111
|
+
details: Schema.Array(PermissionDetail),
|
|
112
|
+
body: Schema.Unknown,
|
|
113
|
+
},
|
|
114
|
+
).pipe(Category.withAuthError) {}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* `quotas_exceeded` (403) -- creating the resource would exceed an
|
|
118
|
+
* Organization quota (`details[].quota` vs `details[].current`). Raise the
|
|
119
|
+
* quota in the console or free capacity; retrying does not help.
|
|
120
|
+
*/
|
|
121
|
+
export class QuotasExceededError extends Schema.TaggedError<QuotasExceededError>()(
|
|
122
|
+
"QuotasExceededError",
|
|
123
|
+
{
|
|
124
|
+
message: Schema.String,
|
|
125
|
+
details: Schema.Array(QuotaDetail),
|
|
126
|
+
body: Schema.Unknown,
|
|
127
|
+
},
|
|
128
|
+
).pipe(Category.withQuotaError) {}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* `not_found` (404) -- no `resource` with `resource_id` is visible to this
|
|
132
|
+
* key. Also raised for the legacy `unknown_resource` envelope when its
|
|
133
|
+
* message names the missing UUID.
|
|
134
|
+
*/
|
|
135
|
+
export class ResourceNotFoundError extends Schema.TaggedError<ResourceNotFoundError>()(
|
|
136
|
+
"ResourceNotFoundError",
|
|
137
|
+
{
|
|
138
|
+
message: Schema.String,
|
|
139
|
+
resource: Schema.optional(Schema.String),
|
|
140
|
+
resource_id: Schema.optional(Schema.String),
|
|
141
|
+
body: Schema.Unknown,
|
|
142
|
+
},
|
|
143
|
+
).pipe(Category.withNotFoundError) {}
|
|
144
|
+
|
|
145
|
+
/** `expired` (410) -- the resource existed but expired at `expired_since`. */
|
|
146
|
+
export class ResourceExpiredError extends Schema.TaggedError<ResourceExpiredError>()(
|
|
147
|
+
"ResourceExpiredError",
|
|
148
|
+
{
|
|
149
|
+
message: Schema.String,
|
|
150
|
+
resource: Schema.optional(Schema.String),
|
|
151
|
+
resource_id: Schema.optional(Schema.String),
|
|
152
|
+
expired_since: Schema.optional(Schema.String),
|
|
153
|
+
body: Schema.Unknown,
|
|
154
|
+
},
|
|
155
|
+
).pipe(Category.withNotFoundError) {}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* `locked` (423) -- Scaleway has locked the resource (abuse, billing or
|
|
159
|
+
* legal hold); it cannot be changed until the lock is lifted.
|
|
160
|
+
*/
|
|
161
|
+
export class ResourceLockedError extends Schema.TaggedError<ResourceLockedError>()(
|
|
162
|
+
"ResourceLockedError",
|
|
163
|
+
{
|
|
164
|
+
message: Schema.String,
|
|
165
|
+
resource: Schema.optional(Schema.String),
|
|
166
|
+
resource_id: Schema.optional(Schema.String),
|
|
167
|
+
body: Schema.Unknown,
|
|
168
|
+
},
|
|
169
|
+
).pipe(Category.withLockedError) {}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* `transient_state` (409) -- the resource is mid-transition
|
|
173
|
+
* (`current_state`: `starting`, `stopping`, `deleting`, ...) and refuses the
|
|
174
|
+
* change until it settles. Retryable: the default policy retries it with
|
|
175
|
+
* backoff, the way the official SDKs' `waitFor*` helpers poll.
|
|
176
|
+
*/
|
|
177
|
+
export class TransientStateError extends Schema.TaggedError<TransientStateError>()(
|
|
178
|
+
"TransientStateError",
|
|
179
|
+
{
|
|
180
|
+
message: Schema.String,
|
|
181
|
+
resource: Schema.optional(Schema.String),
|
|
182
|
+
resource_id: Schema.optional(Schema.String),
|
|
183
|
+
current_state: Schema.optional(Schema.String),
|
|
184
|
+
body: Schema.Unknown,
|
|
185
|
+
},
|
|
186
|
+
).pipe(Category.withConflictError, Category.withRetryable()) {}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* `already_exists` (409) -- a `resource` with that identity (name, domain,
|
|
190
|
+
* key) already exists, as `resource_id`.
|
|
191
|
+
*/
|
|
192
|
+
export class AlreadyExistsError extends Schema.TaggedError<AlreadyExistsError>()(
|
|
193
|
+
"AlreadyExistsError",
|
|
194
|
+
{
|
|
195
|
+
message: Schema.String,
|
|
196
|
+
resource: Schema.optional(Schema.String),
|
|
197
|
+
resource_id: Schema.optional(Schema.String),
|
|
198
|
+
help_message: Schema.optional(Schema.String),
|
|
199
|
+
body: Schema.Unknown,
|
|
200
|
+
},
|
|
201
|
+
).pipe(Category.withAlreadyExistsError) {}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* `precondition_failed` (412) -- the resource is in a state that forbids the
|
|
205
|
+
* call (`precondition`, e.g. `resource_still_in_use`, `attribute_must_be_set`)
|
|
206
|
+
* and will stay that way until the caller changes something.
|
|
207
|
+
*/
|
|
208
|
+
export class PreconditionFailedError extends Schema.TaggedError<PreconditionFailedError>()(
|
|
209
|
+
"PreconditionFailedError",
|
|
210
|
+
{
|
|
211
|
+
message: Schema.String,
|
|
212
|
+
precondition: Schema.optional(Schema.String),
|
|
213
|
+
help_message: Schema.optional(Schema.String),
|
|
214
|
+
body: Schema.Unknown,
|
|
215
|
+
},
|
|
216
|
+
).pipe(Category.withConflictError) {}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* `out_of_stock` -- the zone has no capacity left for `resource` (an
|
|
220
|
+
* Instance or Elastic Metal offer). Try another zone or offer.
|
|
221
|
+
*/
|
|
222
|
+
export class OutOfStockError extends Schema.TaggedError<OutOfStockError>()("OutOfStockError", {
|
|
223
|
+
message: Schema.String,
|
|
224
|
+
resource: Schema.optional(Schema.String),
|
|
225
|
+
body: Schema.Unknown,
|
|
226
|
+
}).pipe(Category.withQuotaError) {}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Unknown Scaleway error -- returned when nothing else matches the failure.
|
|
230
|
+
* `code` is the envelope's `type` when it had one.
|
|
231
|
+
*/
|
|
232
|
+
export class UnknownScalewayError extends Schema.TaggedError<UnknownScalewayError>()(
|
|
233
|
+
"UnknownScalewayError",
|
|
234
|
+
{
|
|
235
|
+
code: Schema.optional(Schema.String),
|
|
236
|
+
message: Schema.optional(Schema.String),
|
|
237
|
+
body: Schema.Unknown,
|
|
238
|
+
},
|
|
239
|
+
).pipe(Category.withServerError) {}
|
|
240
|
+
|
|
241
|
+
/** Schema parse error wrapper. */
|
|
242
|
+
export class ScalewayParseError extends Schema.TaggedError<ScalewayParseError>()(
|
|
243
|
+
"ScalewayParseError",
|
|
244
|
+
{
|
|
245
|
+
body: Schema.Unknown,
|
|
246
|
+
cause: Schema.Unknown,
|
|
247
|
+
},
|
|
248
|
+
).pipe(Category.withParseError) {}
|
|
249
|
+
|
|
250
|
+
/** The errors Scaleway's `type` envelope can name. */
|
|
251
|
+
export type ScalewayErrors =
|
|
252
|
+
| InvalidArgumentsError
|
|
253
|
+
| DeniedAuthenticationError
|
|
254
|
+
| PermissionsDeniedError
|
|
255
|
+
| QuotasExceededError
|
|
256
|
+
| ResourceNotFoundError
|
|
257
|
+
| ResourceExpiredError
|
|
258
|
+
| ResourceLockedError
|
|
259
|
+
| TransientStateError
|
|
260
|
+
| AlreadyExistsError
|
|
261
|
+
| PreconditionFailedError
|
|
262
|
+
| OutOfStockError;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Default Scaleway operation errors.
|
|
266
|
+
*
|
|
267
|
+
* EVERY operation carries the whole set: the specs declare no failures, and
|
|
268
|
+
* any Scaleway API can answer with any `type` -- the error channel says so
|
|
269
|
+
* rather than pretending a `404` is impossible on a route that never
|
|
270
|
+
* declared one. The status classes cover failures whose body has no
|
|
271
|
+
* recognised `type` (a proxy error page, a gateway timeout).
|
|
272
|
+
*/
|
|
273
|
+
export type DefaultErrors =
|
|
274
|
+
| CoreDefaultErrors
|
|
275
|
+
| CoreBadRequest
|
|
276
|
+
| CoreForbidden
|
|
277
|
+
| CoreNotFound
|
|
278
|
+
| CoreConflict
|
|
279
|
+
| CoreUnprocessableEntity
|
|
280
|
+
| CoreLocked
|
|
281
|
+
| ScalewayErrors
|
|
282
|
+
| UnknownScalewayError
|
|
283
|
+
| ScalewayParseError;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The errors declared on the Scaleway services: any operation can return
|
|
287
|
+
* them, and every generated operation lists them as its `serviceErrors`.
|
|
288
|
+
* The specs declare no failures, and any Scaleway API can answer with any
|
|
289
|
+
* `type`: each class the `type` envelope names ({@link ScalewayErrors}), and
|
|
290
|
+
* each of core's status classes, for a failure whose body has no recognised
|
|
291
|
+
* `type` (and `TooManyRequests` for `too_many_requests`).
|
|
292
|
+
*/
|
|
293
|
+
export const ScalewayServiceErrors = [
|
|
294
|
+
...API_ERRORS,
|
|
295
|
+
InvalidArgumentsError,
|
|
296
|
+
DeniedAuthenticationError,
|
|
297
|
+
PermissionsDeniedError,
|
|
298
|
+
QuotasExceededError,
|
|
299
|
+
ResourceNotFoundError,
|
|
300
|
+
ResourceExpiredError,
|
|
301
|
+
ResourceLockedError,
|
|
302
|
+
TransientStateError,
|
|
303
|
+
AlreadyExistsError,
|
|
304
|
+
PreconditionFailedError,
|
|
305
|
+
OutOfStockError,
|
|
306
|
+
] as const;
|
|
307
|
+
export type ScalewayServiceError = InstanceType<(typeof ScalewayServiceErrors)[number]>;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/scaleway -- Scaleway API SDK for Effect.
|
|
3
|
+
*
|
|
4
|
+
* `./services` and `./unstable-services` are generated by
|
|
5
|
+
* `scripts/generate.ts` from the Smithy models in `.generated-specs`
|
|
6
|
+
* (written by `scripts/convert.ts` from the OpenAPI documents mirrored at
|
|
7
|
+
* `specs/spec-mirror-scaleway/specs/`). Everything else in this folder is
|
|
8
|
+
* hand-written.
|
|
9
|
+
*
|
|
10
|
+
* One module per Scaleway API service and version, named after it
|
|
11
|
+
* (`instanceV1`, `k8sV1`, `lbZonedV1`, `accountProjectV3`, ...), imported
|
|
12
|
+
* as `@distilled.cloud/scaleway/<slug>` (`instance_v1`). Alpha and beta
|
|
13
|
+
* versions are imported as `@distilled.cloud/scaleway/unstable/<slug>`
|
|
14
|
+
* (`instance_v2alpha1`, `domain_v2beta1`). Auth is an
|
|
15
|
+
* API secret key (`SCW_SECRET_KEY`) sent as `X-Auth-Token`; a call that
|
|
16
|
+
* omits `region` / `zone` uses `SCW_DEFAULT_REGION` / `SCW_DEFAULT_ZONE`
|
|
17
|
+
* (default `fr-par` / `fr-par-1`).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Effect, Layer } from "effect";
|
|
22
|
+
* import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
23
|
+
* import * as Scaleway from "@distilled.cloud/scaleway";
|
|
24
|
+
* import * as InstanceV1 from "@distilled.cloud/scaleway/instance_v1";
|
|
25
|
+
*
|
|
26
|
+
* const program = Effect.gen(function* () {
|
|
27
|
+
* const { servers } = yield* InstanceV1.listServers({ zone: "fr-par-1" });
|
|
28
|
+
* return servers;
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* program.pipe(
|
|
32
|
+
* Effect.provide(
|
|
33
|
+
* Layer.mergeAll(
|
|
34
|
+
* FetchHttpClient.layer,
|
|
35
|
+
* Scaleway.CredentialsFromEnv,
|
|
36
|
+
* ),
|
|
37
|
+
* ),
|
|
38
|
+
* Effect.runPromise,
|
|
39
|
+
* );
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export * from "./credentials.ts";
|
|
43
|
+
export * from "./errors.ts";
|
|
44
|
+
export * as T from "./traits.ts";
|
|
45
|
+
export {
|
|
46
|
+
ScalewayProtocol,
|
|
47
|
+
scalewayError,
|
|
48
|
+
type ScalewayOpError,
|
|
49
|
+
type ScalewayOpContext,
|
|
50
|
+
} from "./protocol.ts";
|
|
51
|
+
export { paginateByTotalCount, paginateToken } from "./pagination.ts";
|
|
52
|
+
export * as Retry from "./retry.ts";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getPath, type PaginationStrategy } from "@distilled.cloud/core/pagination";
|
|
2
|
+
/**
|
|
3
|
+
* Scaleway pagination -- hand-written.
|
|
4
|
+
*
|
|
5
|
+
* Most Scaleway list operations page by NUMBER: `?page=N&page_size=M` in
|
|
6
|
+
* (Instance v1 spells the size `per_page`), the collection beside
|
|
7
|
+
* `total_count` out. Core's `paginatePageNumber` expects the NEXT page
|
|
8
|
+
* number in the response, which Scaleway never sends; this strategy does
|
|
9
|
+
* what the official SDKs' `fetchPaginated` does
|
|
10
|
+
* (scaleway-sdk-js `packages/client/src/scw/fetch/resource-paginator.ts`):
|
|
11
|
+
* size the pages by the first one and request `page+1` until
|
|
12
|
+
* `ceil(total_count / first page length)` pages are read.
|
|
13
|
+
*
|
|
14
|
+
* Instance v1 answers `total_count` as the `X-Total-Count` header; the
|
|
15
|
+
* protocol folds it into the body before this strategy reads it.
|
|
16
|
+
*
|
|
17
|
+
* The few lists that page by cursor (`page_token` in, `next_page_token`
|
|
18
|
+
* out -- Audit Trail, Cockpit, Key Manager, ...) use core's `paginateToken`.
|
|
19
|
+
*/
|
|
20
|
+
import * as Effect from "effect/Effect";
|
|
21
|
+
import * as Stream from "effect/Stream";
|
|
22
|
+
|
|
23
|
+
export type { PaginatedTrait, PaginationStrategy } from "@distilled.cloud/core/pagination";
|
|
24
|
+
export { paginateToken } from "@distilled.cloud/core/pagination";
|
|
25
|
+
import { missingPaginationConfig } from "@distilled.cloud/core/pagination";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Stream of pages using Scaleway's `page` / `total_count` envelope: request
|
|
29
|
+
* `page`, `page+1`, ... until the pages read cover `total_count` or a page
|
|
30
|
+
* comes back empty.
|
|
31
|
+
*/
|
|
32
|
+
export const paginateByTotalCount: PaginationStrategy = (operation, input, pagination) => {
|
|
33
|
+
const inputToken = pagination.inputToken;
|
|
34
|
+
const totalCountPath = pagination.outputToken;
|
|
35
|
+
const itemsPath = pagination.items;
|
|
36
|
+
if (!inputToken || !totalCountPath || !itemsPath) {
|
|
37
|
+
return missingPaginationConfig(
|
|
38
|
+
"Total-count pagination requires inputToken, outputToken and items",
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type State = { page: number; lastPage: number | undefined; done: boolean };
|
|
43
|
+
const startPage = typeof input[inputToken] === "number" ? (input[inputToken] as number) : 1;
|
|
44
|
+
|
|
45
|
+
return Stream.unfold({ page: startPage, lastPage: undefined, done: false } as State, (state) =>
|
|
46
|
+
Effect.gen(function* () {
|
|
47
|
+
if (state.done) return undefined;
|
|
48
|
+
|
|
49
|
+
const response = yield* operation({ ...input, [inputToken]: state.page } as typeof input);
|
|
50
|
+
|
|
51
|
+
const items = getPath(response, itemsPath) as readonly unknown[] | undefined;
|
|
52
|
+
const length = Array.isArray(items) ? items.length : 0;
|
|
53
|
+
let lastPage = state.lastPage;
|
|
54
|
+
if (lastPage === undefined) {
|
|
55
|
+
const total = getPath(response, totalCountPath);
|
|
56
|
+
// Sized by the first page read, as the official SDKs do: the server
|
|
57
|
+
// may cap `page_size` below what was asked.
|
|
58
|
+
lastPage = typeof total === "number" && length > 0 ? Math.ceil(total / length) : state.page;
|
|
59
|
+
}
|
|
60
|
+
const done = length === 0 || state.page >= lastPage;
|
|
61
|
+
|
|
62
|
+
return [response, { page: state.page + 1, lastPage, done } satisfies State] as const;
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
};
|