Hey @mohsin, thanks a lot! I just tried but it is still not working for me.
I mainly updated all the sdk packages to version 12:
"@ceramic-sdk/events": "^0.12.0",
"@ceramic-sdk/flight-sql-client": "^0.12.0",
"@ceramic-sdk/http-client": "^0.12.0",
"@ceramic-sdk/identifiers": "^0.12.0",
"@ceramic-sdk/model-client": "^0.12.0",
"@ceramic-sdk/model-instance-client": "^0.12.0",
"@ceramic-sdk/model-protocol": "^0.12.0",
and also for the ceramic node I used the latest version of docker (doing docker pull before docker compose up to ensure the image is updated): public.ecr.aws/r5b3e0r5/3box/ceramic-one:latest
After that, I mainly followed the same process I explained at the beginning of this post, using same model for different instances of the model using the same field under accountRelation, so the instances should have the same stream, but when I try to update the new set instance I got an error updating it (if I use createInstance it will work properly).
model:
// 1. Create a model client
const modelClient = new ModelClient({
ceramic,
did: authenticatedDID,
});
// 2. Define the Model's Schema Definition
const DeploymentIndexModel: ModelDefinition = {
version: "2.0",
name: "DeploymentIndex development",
description: "A unique anchor document for a specific application deployment development 2",
// This model is controlled by an admin/system DID.
// Each deployment is a unique instance.
accountRelation: { type: "set", fields: ["environment"], },
interface: false,
implements: [],
schema: {
type: "object",
$schema: "https://json-schema.org/draft/2020-12/schema",
properties: {
// Human-readable name for the deployment
environment: { type: "string", maxLength: 100 },
// Optional version for this deployment
deployment_version: { type: "string", maxLength: 100 },
},
required: ["environment", "deployment_version"],
additionalProperties: false,
},
};
// 3. Create the Model Stream
const modelStream = await modelClient.createDefinition(DeploymentIndexModel);
await new Promise(resolve => setTimeout(resolve, 3000));
console.log("modelStream", modelStream);
// 4. Get the Stream's Model Definition
const modelDefinition = await modelClient.getModelDefinition(modelStream);
await new Promise(resolve => setTimeout(resolve, 3000));
console.log("modelDefinition", modelDefinition);
Logs from previous execution:
modelStream StreamID(kjzl6hvfrbw6cabymzratp29my20da270dioricr21kr8es4gd8hno1cjjm86nx)
modelDefinition {
accountRelation: { fields: [ 'environment' ], type: 'set' },
description: 'A unique anchor document for a specific application deployment development 2',
implements: [],
interface: false,
name: 'DeploymentIndex development',
schema: {
'$schema': 'https://json-schema.org/draft/2020-12/schema',
additionalProperties: false,
properties: { deployment_version: [Object], environment: [Object] },
required: [ 'environment', 'deployment_version' ],
type: 'object'
},
version: '2.0'
}
Creation of new instances with same required fields (so they should return same streamid):
const deploymentIdModelStreamId = StreamID.fromString("kjzl6hvfrbw6cabymzratp29my20da270dioricr21kr8es4gd8hno1cjjm86nx");
// 1. Instantiate a ModelInstanceClient
const modelInstanceClient = new ModelInstanceClient({
ceramic,
did: authenticatedDID,
});
await new Promise(resolve => setTimeout(resolve, 3000));
const devDeploymentInstance = await modelInstanceClient.createSingleton({
model: deploymentIdModelStreamId,
controller: authenticatedDID,
});
await new Promise(resolve => setTimeout(resolve, 8000));
console.log("instance stream", devDeploymentInstance.baseID.toString());
await new Promise(resolve => setTimeout(resolve, 8000));
await modelInstanceClient.updateDocument({
streamID: devDeploymentInstance.baseID.toString(),
newContent: {
environment: "devDeploymentTest",
deployment_version: `v_${Date.now()}`,
},
shouldIndex: true,
});
await new Promise(resolve => setTimeout(resolve, 8000));
const currentStateAfterModify = await modelInstanceClient.getDocumentState(devDeploymentInstance.baseID);
await new Promise(resolve => setTimeout(resolve, 8000));
console.log("currentStateAfterModify", currentStateAfterModify, "baseId", devDeploymentInstance.baseID);
And these are the logs:
instance stream k2t6wzhkhabz4593z28rnykfvf91kscvh2axz3xvyk54uu4gnuu1q0dbgrjdy4
file:///
throw new Error(`Failed to fetch stream state: ${error.message}`);
^
Error: Failed to fetch stream state: undefined
Node.js v20.18.3
Looks like it is not able to retrieve the information from the new created set instance. If I just change the accountRelation to “single” and remove the “fields” array, it works properly and I am able to retrieve everything.
Am I doing something wrong?
Thanks in advance! 