Closed cegrnd closed 2 years ago
doesn't error out when specifying services:
const ckConfig: CloudKit.CloudKitConfig = { services: { fetch: fetch }, containers: [ ckContainerConfig ] };
Hello @cegrnd! Thank you for the report and the solution. So I assume that window.fetch
was not present in the setup.
Exactly right. I am new to js/ts so it didn't quite make sense initially but adding fetch to services in the cloudkit config was enough to confirm there was nothing wrong with tsl-apple-cloudkit. Thanks for putting that type library together BTW, looks great. Not sure why Apple couldn't release something like that (their recent cktool js does support typescript).
Sharing some sample code with a basic setup in case it helps others exploring PWA as an alternative to native apps:
------ global.d.ts file in src/types
import * as CloudKit from 'tsl-apple-cloudkit';
export { };
declare global { interface Window { ck: CloudKit.CloudKit; } }
----- index.html
inside body:
----- app-index.ts
import "./types/global.d.ts";
const ckDefaultContainer = window.ck.getDefaultContainer() const db = ckDefaultContainer.privateCloudDatabase console.log(db.containerIdentifier)
Thanks! Maybe Apple will provide TypeScript declarations with version 3 of CloudKit JS. It would be good to have something official.
Hi,
I am getting the following error in the vsCode console when trying to create a CloudKit instance (see below). Any suggestions? Thanks
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'ArrayBuffer') at (..../node_modules/tsl-apple-cloudkit/index.js:13:5004)
at (..../node_modules/tsl-apple-cloudkit/index.js:13:5045)
at t2 (..../node_modules/tsl-apple-cloudkit/index.js:12:417)
at (..../node_modules/tsl-apple-cloudkit/index.js:13:4512)
at t2 (..../node_modules/tsl-apple-cloudkit/index.js:12:417)
at (..../node_modules/tsl-apple-cloudkit/index.js:13:945)
at t2 (..../node_modules/tsl-apple-cloudkit/index.js:12:417)
...
import * as CloudKit from 'tsl-apple-cloudkit';
const ckContainerConfig: CloudKit.ContainerConfigLike = { containerIdentifier: 'xxxxx', apiTokenAuth: { apiToken: 'xxxxx', persist: false, signInButton: { id: 'apple-sign-in-button', theme: 'black' }, signOutButton: { id: 'apple-sign-out-button', theme: 'black' } }, environment: 'development' } const ckConfig: CloudKit.CloudKitConfig = { containers: [ ckContainerConfig ] }; const ck = CloudKit.configure(ckConfig);